SPRING/PropertyPlaceholderConfigurer 절대 경로 인식

[ SPRING ] PropertyPlaceholderConfigurer 절대 경로로 location 읽어오기

정윤재 2013. 4. 2. 15:05

원래 spring 과 DB 설정을 읽어오려면

 

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
      <value>classpath:conf/myBatis/db.properties</value>
      </property>
 </bean>

 

 

이런 식으로 classpath 내에서 properties 파일을 읽어 올 수 있습니다.

 

그런데 executable jar 로 실행 시키려고 한다면 jar 파일 안에 properties 가

 

묶이게 되므로 주기적인 properties 설정이 불가능 하고 변경이 있을 때마다

 

build 를 다시 해줘야 합니다.

 

해당 설정을 바꾸기 위해 절대 경로로 파일을 읽을 수 있도록 설정을 바꾸려면

 

 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
      <value>file:/home/tbiz/apps/broker-app-1.0/db.properties</value>
  </property>
 </bean>

 

와 같이 바꿔주면 됩니다.