Reputation: 11
How to handle multiple property files in spring with placeholderconfigurer?
I have an application context in Common project with following bean entry:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:database.properties" />
</bean>
And in Service layer project I have another application context file with this bean entry:
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="location" value="classpath:kestrel.properties" />
</beans:bean>
The entries in property file are like :
database proprties:
URL= xxx
USERNAME = xxx
PWD = xxx
kestrel.properties:
mediacast.url = xxx
With these setting, when I start my tomcat server I get expection like:
Could not resolve placeholder 'mediacast.url' from kestrel.properties - property file.
Thanks in advance for any help!
Upvotes: 1
Views: 1445
Reputation: 81587
On my application, I do that:
<bean id="envPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>one/path/to/file</value>
<value>another/path/to/file</value>
</list>
</property>
</bean>
Upvotes: 2