속성

2012-01-11 3 views
0

내가 applicationContext.xml 내부속성

return new ClassPathXmlApplicationContext("applicationContext.xml"); 

내가

<bean id="dataSource" 
    class="org.springframework.jdbc.datasource.SingleConnectionDataSource"> 
    <property name="driverClassName"> 
     <value>${db.driverclassname}</value> 
    </property> 
    ... 
</bean> 

나는 내 콩 중 하나를 배선 해요으로 static main 방법 안에 내 Spring 컨텍스트를 만드는거야 스프링 컨텍스트 XML에서 해결되지 않습니다 값이 db.driverclassname 인 내 클래스 경로에 .properties 파일이 있습니다.

Property 'driverClassName' threw exception; 
    nested exception is java.lang.IllegalStateException: 
     Could not load JDBC driver class [${db.driverclassname}] 

내가 잘못 뭐하는 거지 :

불행히도 나는 다음과 같은 오류를 받고 있어요? 스프링 2.5.5를 사용하고 있습니다.

답변

5

PropertyPlaceholderConfigurer이 필요하지 않습니까?

<bean id="propertyConfigurer"  
     class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="location"> 
     <value>classpath:project.properties</value> 
    </property> 
</bean> 

This article 세부 정보 사용.

0
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="locations"> 
      <list> 
       <value>classpath:your.properties</value> 
      </list> 
     </property> 
     <property name="ignoreUnresolvablePlaceholders" value="true"/> 
    </bean>