什么是具有多个位置的Spring属性占位符配置器中的属性解析顺序?
假设我有一个配置:
<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
second.properties具有属性my.url = second.url
first.properties has property "my.url=first.url" second.properties has property "my.url=second.url"
所以哪个值将被注入myUrlbean?是否有任何已定义的属性解析顺序?
So which value will be injected to the "myUrl" bean? Is there is any defined order of properties resolution?
PropertiesLoaderSupport.setLocation 状态
设置要加载的属性文件的位置。
Set locations of properties files to be loaded.
可以指向经典属性文件或遵循JDK 1.5属性XML格式的XML文件。
Can point to classic properties files or to XML files that follow JDK 1.5's properties XML format.
注意:在以后的文件中定义的属性将在重叠键的情况下,覆盖先前定义的文件属性。因此,请确保最具体的文件是给定位置列表中的最后一个文件。
Note: Properties defined in later files will override properties defined earlier files, in case of overlapping keys. Hence, make sure that the most specific files are the last ones in the given list of locations.
所以my.url的值在second.properties中将覆盖first.properties中my.url的值。
So the value of my.url in second.properties will override the value of my.url in first.properties.