Hi,
I would like to keep default properties file in my app jar (under src/main/resources) and be able to override this location, if the JVM is being ran with a specific var such as -Dapp.conf.dir=//opt/some/dir.
I've managed to get this behavior by ordering the locations array. it seems that the latter location will override the previous. But since this is a dangerous un-documented behavior I would prefer something more "safe".
Before I extend PropertyPlaceHolderConfigurer to process a "classpath:/" resource only if there's no "file:/" resource, is there anything I'm missing in spring which gives this behavior out of the box?
so the required behavior is:
- verify if there's a ${app.conf.dir} set as system property
- if there is, load ${app.conf.dir}/*.properties
-- else load classpath:/*.properties
here's an excerpt from my context.xml:
Code:<bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="searchSystemEnvironment" value="true" /> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> <property name="locations"> <list> <value>classpath:/META-INF/*.properties</value> <!-- this happens to override previous properties due to the implementation... --> <value>file:/${app.config.dir}/*.properties</value> </list> </property> </bean>


Reply With Quote
