I’m writing scripts to deploy apps under Tomcat. There are different ways of configuring these apps:
- Keeping properties files in a source directories like WEB-INF which would mean we need to extract sources and replace those files with what we need for particular env
- Configuration based on env properties, this looks like a bad option as for me, files are more explicit and less magic, and less work on separating apps on the same machine
- There are also options to configure TOMCAT_HOME/conf/[app_name].xml and treat those properties as env vars in our apps. But in this way it won’t be possible to move to Jetty for instance if we would want to do that because these files are Tomcat-specific.
Could someone provide other options and share their opinions on the listed above? Consider these criteria: easiness of configuring, portability, standards, explicitness (don’t like magic, other people may not understand it), OS (main OS is Linux, but others may want to run it on Windows).
You can use configuration based on env properties by using files. What I mean is that you can write a Context.xml file under the META-INF of your web application setting up the environment or configuration following this rules.
I find that using env properties provides easy configuration, is based on context and dependency injection. You can use the new java API’s eg. the @Resource annotation. It will work under any application server, etc.