Reputation: 645
I want to load multiple properties files using <util:properties>
tag in a spring 3 application.
I searched on the blogs, but cannot get the correct path to do this.
Hopefully somebody give me the answer to overcome this problem.
Upvotes: 10
Views: 11763
Reputation: 762
Actually <util:properties>
is just convenient tag for org.springframework.beans.factory.config.PropertiesFactoryBean
. And PropertiesFactoryBean
does support multiple locations.
So it is possible to create bean with Properties
this way:
<bean id="myProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:myprops-common.properties</value>
<value>classpath:myprops-override.properties</value>
<value>classpath:some-more-props-here.properties</value>
</list>
</property>
</bean>
Upvotes: 24
Reputation: 80166
util:properties seems to support only 1 properties file (reference). You might want to use the configuration suggested by @peperg.
Upvotes: 3
Reputation: 12212
My solution
<context:property-placeholder location="classpath*:*.properties,file:/some/other/path/*.properties" />
Upvotes: 10