Tuesday, June 19, 2012

Spring Active Profiles - externalizing to properties files

a great solution over on stackoverflow works essentially like this;

- create your own implementation of an ApplicationContextInitializer
- read in an external reference (could even be a database, but properties file makes more sense)
- get the ConfigurableEnvironment from the passed context
- set the spring active profiles

to use this inside something like a WAR file, use the web.xml and set the file as an init param for the context.

No comments:

Post a Comment