<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>config2.properties</value>
<value>config1.properties</value>
</list>
</property>
</bean>注意如果有同名属性 后边的配置文件会覆盖前边的配置文件
如上例 config1.properties 里的属性 如果和config2.properties 里的属性重名 我们得到值是config1.properties 里面的
本文介绍了Spring框架中配置文件的加载顺序及解析过程,重点解释了当存在多个配置文件时,如何通过PropertyPlaceholderConfigurer指定配置文件加载顺序,并说明了属性重名时的覆盖规则。
970

被折叠的 条评论
为什么被折叠?



