How to provide a context configuration for a web application in Tomcat?

前端 未结 6 1531
星月不相逢
星月不相逢 2020-12-04 08:30

I have a web application that relies on some resources and parameters to be configured after it is installed, like a JDBC connection.

What I have come up with is pro

6条回答
  •  悲哀的现实
    2020-12-04 09:14

    I don't know how to modify Tomcat's behaviour but I could think of 2 different solutions:

    1. different (parameterized) build scripts for each environment, so that you define a parameter called env to your build scripts and depending on the value it places the environment specific context.xml in your WAR during build.
    2. Create an install script for each environment that first redeploys the WAR file (places it in webapps directory) and then makes modifications to the Tomcat installation depending on environment, e.g. different hostname for JDBC DataSource in context.xml.

    I make heavy use of the latter approach as it works in enterprise environments. Separation of duties policies often prohibit the dev team from knowing e.g. production database passwords. Option #2 solves this problem because only IT operations have access to the environment specific install scripts after they have been created.

提交回复
热议问题