I have the following Spring XML-based config:
<!--
These properties define the db.type property.
-->
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="order" value="1"/>
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<!-- contains default db.type -->
<value>classpath:/default-cfg.properties</value>
<!-- db.type can be overridden by optional properties in the app work dir -->
<value>file:${app.work.dir}/cfg.properties</value>
</list>
</property>
</bean>
<!-- db.type should be used to get DB specific config properties -->
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="order" value="2"/>
<property name="ignoreUnresolvablePlaceholders" value="false" />
<property name="ignoreResourceNotFound" value="false" />
<property name="locations">
<list>
<!-- does not work, ${db.type} does not get resolved -->
<value>classpath:/default-cfg-${db.type}.properties</value>
</list>
</property>
</bean>
The problem is that the property in the classpath:/default-cfg-${db.type}.properties
location does not get resolved even though db.type
is defined by the first property placeholder configurer.
I keep getting the following error in the log:
class path resource [default-cfg-${db.type}.properties] cannot be opened because it does not exist
Is there any way to use properties in the PropertyPlaceholderConfigurer's locations attribute? I want to avoid using JVM system property to set the db.type value.
Thank you, Jan