title: How to set active spring 3.1 environment profile via a properites file and not via an env variable or system property
body: <p>We use the new environment profiles feature of spring 3.1. We currently set the active profile by setting the environment variable spring.profiles.active=xxxxx on the server to which we deploy the application.</p>
  
  <p>We think this is a suboptimal solution as the war file we want to deploy should just have an additional properties file which sets the environment in which the spring app context should load so the deployment is not dependent on some env var set on the server.</p>
  
  <p>I tried to figure out how to do that and found:</p>
  
  <p><a href="http://static.springsource.org/spring/docs/3.1.0.M2/javadoc-api/org/springframework/core/env/ConfigurableEnvironment.html#setActiveProfiles%28java.lang.String...%29"><code>ConfigurableEnvironment.setActiveProfiles()</code></a></p>
  
  <p>which I can use to programmatically set the profile but then I still don't know where and when to execute this code. Somewhere where the spring context loads up? Can I load the parameter I want to pass to the method from a properties file?</p>
  
  <p>UPDATE: I just found at <a href="http://docs.oracle.com/javaee/1.4/api/javax/servlet/ServletContextListener.html?is-external=true">docs</a> which I might be able to implement to set the active profile?</p>