I'd like to have some resources required but ignore other one if its missing... How to do that? As I see it I can only do
<context:property-placeholder
ignore-resource-not-found="true"
location="required.properties, not-required-override.properties" />
Which affects every config listed mentioned there.
// EDIT This is a working example
<bean id="requiredProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:database.properties</value>
<value>classpath:storage.properties</value>
<value>classpath:log4j.properties</value>
<value>classpath:mailing.properties</value>
</list>
</property>
</bean>
<context:property-placeholder
properties-ref="requiredProperties" ignore-resource-not-found="true"
location="file:\${user.dir}/config/cvnizer.properties" />
Add a PropertiesFactoryBean
element for the required dependencies and simply wire the properties to the <context:property-placeholder />
.
<bean id="requiredProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations" value="classpath:file1.properties,classpath:file2.properties" />
</bean>
<context:property-placeholder properties-ref="requiredProperties" ignore-resource-not-found="true" location="not-required-override.properties" />
The properties will me merged at runtime so you can still override when a properties file is read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With