2

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?

birdy
  • 9,286
  • 24
  • 107
  • 171

1 Answers1

1

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

Community
  • 1
  • 1
Sujith Surendranathan
  • 2,569
  • 17
  • 21
  • hmm I see how to set the variable in tomcat. but how can i access it from my web.xml? Will I have to make applicationConfiguration class especially to set this variable or is there a way to do it directly from web.xml itself. – birdy Nov 14 '12 at 19:49