假设我有一个配置:
<bean id="batchJobProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>first.properties</value>
<value>second.properties</value>
</list>
</property>
</bean>
first.properties 具有属性“my.url=first.url”
secondary.properties 具有属性“my.url=second.url”
那么哪个值将被注入到“myUrl”bean 中?属性解析是否有任何定义的顺序?
javadoc 为PropertiesLoaderSupport.setLocation states
设置要加载的属性文件的位置。
可以指向经典属性文件或遵循 JDK 1.5 属性 XML 格式的 XML 文件。
注意:如果键重叠,后面文件中定义的属性将覆盖前面文件中定义的属性。因此,请确保最具体的文件是给定位置列表中的最后一个文件。
因此,second.properties 中 my.url 的值将覆盖 first.properties 中 my.url 的值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)