Reputation: 386
What can I do for best practice management properties?
My service developed using spring-web.
Upvotes: 0
Views: 66
Reputation: 7950
You have 2 issues:
1) How to have your properties outside of the war file, I would suggest you do the following:
@PropertySource(value={"classpath:/config.properties", "file:${configRoot}/config.properties"}, ignoreResourceNotFound = true)
Then when you start your app you can specify configRoot as a system property to the JVM i.e -DconfigRoot=/var/config. You can then specify a default config which will be pulled from inside the war. Using the ignoreResourceNotFound if the file:${configRoot}/config.properties"} can not be found the first one will be used. i.e. you can have a default inside the war and override it at runtime with the JVM system parameter.
2) How to automatically refresh
Look at this answer to tell spring to refresh it's properties on a schedule:
Upvotes: 1