간단히 설명을 하면
1. web.xml 서버띄울때 필요한 정보 입력
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/applicationContext*.xml</param-value>
</context-param>
2. applicationContext*.xml 파일 내부 설정
<import resource="database.xml"/> <!--DB설정파일-->
<context:property-placeholder location="classpath*:properties/local.properties" />
추가)database.xml 예시파일
${db.mail.driverClassName}이와 같은 정보가 properties에 기입되어있다
<bean id="dataSource" class="해당 클리스" destroy-method="close">
<property name="driverClassName" value="${db.mail.driverClassName}" />
<property name="url" value="${db.mail.url}" />
<property name="username" value="${db.mail.username}" />
<property name="password" value="${db.mail.password}" />
<property name="maxActive" value="5" />
<property name="maxIdle" value="1" />
<property name="minIdle" value="1" />
<property name="maxWait" value="30000" />
<property name="defaultTransactionIsolation" value="1" />
</bean>
3. 설정후 자바와 jsp에서 properties 파일의 값을 읽는방법
java
@Value("${file_dir.url}")
private String fileUploadLo
jsp
<spring:eval var="httpsPort" expression="@applicationProperties.getProperty('port.https')" />
jsp에서 사용하긴 위해서 아래와 같이 bean id가 잡혀있어야함
<!-- Properties -->
<context:property-placeholder location="classpath*:properties/*-${spring.profiles.active}.properties" />
<bean id="applicationProperties" class="클래스명">
<property name="singleton" value="true" />
<property name="location" value="classpath:properties/local.properties" />
</bean>
상세내용은 아래를 참조
http://jijs.tistory.com/entry/spring-%EC%84%A4%EC%A0%95-xml%EA%B3%BC-%EC%86%8C%EC%8A%A4%EC%BD%94%EB%93%9C%EC%97%90%EC%84%9C-properties-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0
댓글 없음:
댓글 쓰기