0
在項目1,我沒有控制有以下配置:Spring多個PropertyPlaceholderConfigurer(在多個項目中)如何覆蓋已定義的屬性?
<bean id="propSource1" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:/sample-properties/prop1.properties"/>
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="-10"/>
</bean>
在另一個項目,我的工作,我有以下配置:
<bean id="propSource2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/sample-properties/prop2.properties</value>
<value>classpath:/sample-properties/prop3.properties</value>
</list>
</property>
<property name="order" value="1000"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
它工作正常預期的情況下,我在prop2.properties或prop3.properties中有相同的屬性,我想覆蓋prop1.properties的值,它總是使用prop1.properties中的值。我研究了很多,但沒有找到有用的東西?
任何建議表示讚賞。
你不能重寫屬性,這樣重寫就可以使用用@ @ PropertySource註解的類或者自己把它們加載到'Environment'中。你必須使用一個新的組件'PropertySourcesPropertyPlaceHolder'。此外,我建議直接使用' '標記代替類。 –
2014-10-30 15:53:23