PropertyPlaceholderConfigurer的注意事项

1、基本的使用方法是
<bean id="propertyConfigurerForWZ" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="location"> 
        <value>classpath:/spring/properties/jdbc.properties</value> 
    </property> 

</bean>
2、当存在多个Properties文件时
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations"> 
       <list> 
          <value>classpath:/spring/properties/jdbc.properties</value> 
          <value>/WEB-INF/conf/spring/system.properties</value> 
        </list> 
    </property> 
</bean> 
3、多个PropertyPlaceholderConfigurer要通过order属性指明加载顺序  
<bean id="propertyConfigurerForWZ" class="org.springframework.beans.factory.
config.PropertyPlaceholderConfigurer"> 
     <property name="order" value="1" /> 
    <property name="ignoreUnresolvablePlaceholders" value="true" /> 
    <property name="location"> 
       <value>classpath:/spring/include/dbQuery.properties</value> 
    </property> 
</bean>
 <bean id="propertyConfigurerForWZ" class="org.springframework.beans.factory.
config.PropertyPlaceholderConfigurer"> 
     <property name="order" value="2" /> 
    <property name="ignoreUnresolvablePlaceholders" value="true" /> 
    <property name="location"> 
       <value>classpath:/spring/include/dubbo.properties</value> 
    </property> 
</bean>
posted @ 2014-12-02 10:56  我爱马培培  阅读(678)  评论(0编辑  收藏  举报