GarlicBread
GarlicBread

Reputation: 2009

Spring: external and internal properties files

I have two Java applications which use Spring (one with v 2.5.4, the other with v 3.1.1.) and are deployed onto Weblogic.

For each application, I'd like Spring to be able to utilise two separate property files - one in the server's filesystem and, if that does not exist for any reason, one included in the application's ear file as a set of "default" values.

Can I specify such a thing using a "context:property-placeholder" entry in the application's applicationContext.xml file?

I've had a look on the Net and not been able to find anything definitive... but could I do something like this, for example?

<!-- Default values loaded first -->
<context:property-placeholder location="classpath:myEarPropertiesFile.properties" />
<!-- Overridden values loaded next -->
<context:property-override location="file:myExternalPropertiesFile.properties" />

Thanks in advance for any thoughts.

Upvotes: 3

Views: 1049

Answers (1)

GarlicBread
GarlicBread

Reputation: 2009

I managed to fix the issue with a PropertiesFactoryBean which was referenced by my PropertyPlaceholderConfigurer.

Upvotes: 1

Related Questions