I’m using sprint 3.1 profiles and have the following code in my web.xml
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>
In order to deploy to the test environment, my workflow currently requires me to change the property value to test, then make a jar and deploy it. However, I’d like to decouple from explicitly making this change.
I want the workflow to be just build the war and deploy it to test. The test environment should have some variable set the spring.profiles.active variable to test.
Question
How do I set a variable, spring.profiles.active, in tomcat7 and configure the web.xml so that it instead reads the variable from servers configuration?
Use the Environment tag in Tomcat. Then in your code, use Context’s lookup method.
Edit: An example (see the question):
Read a Environment Variable in Java with Websphere