springMVC框架中多个配置文件使用PropertyPlaceholderConfigurer读取配置properties文件

来源:互联网 发布:阿里巴巴淘宝怎么赚钱 编辑:程序博客网 时间:2024/05/21 17:58

总结:如果多模块的配置文件使用PropertyPlaceholderConfigurer读取配置properties文件,如果不配置ignoreUnresolvablePlaceholders属性,则不会生成第二PropertyPlaceholderConfigurer2对象对其properties文件;

配置如下:

第一个配置文件spring.xml

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


第二个配置文件activemq-config.xml需要通过PropertyPlaceholderConfigurer 读取 

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="order" value="1" />
        <property name="ignoreUnresolvablePlaceholders" value="true" />
        <property name="location">
            <value>classpath:activemqconfig.properties</value>
        </property>
    </bean>

如果不加

  <property name="order" value="1" />
        <property name="ignoreUnresolvablePlaceholders" value="true" />属性,则activemqconfig.properties不会读取

0 0
原创粉丝点击