Reputation: 15308
I'm writing scripts to deploy apps under Tomcat. There are different ways of configuring these apps:
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).
Upvotes: 2
Views: 215
Reputation: 6939
I'd recommend putting properties into a database table (which of course implies, your application has a datasource).
We prefer this method in our web applications for the following reasons:
In cases where you don't have a database at all, another solution is just to use system properties and read them by System.getProperty(key), which is ok for a system under your control and not too many properties.
Upvotes: 1
Reputation: 1646
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.
Upvotes: 2
Reputation: 658
In my experience it worked well using and environment variable for the conf dir: {APP_NAME}_CONF_DIR. If this is not set the application will default loading from /etc/{app_name}/conf . Most of the time you will not have to set the env. variable as you will use the default dir.
Upvotes: 0