title: Weblogic 10.3.6: activate spring boot profiles from web.xml
body: <p>I'm using Spring Boot on weblogic 10.3.6; however we usually use the embedded tomcat during development.</p>
  
  <p>I'd like to enable a specific Spring profile when on weblogic to accomodate for different configuration/beans to be used when on wl. Since I'm forced to use a web.xml on that ancient version of the application server, I'd like to use web.xml to activate the weblogic profile I need.</p>
  
  <p>This is my web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;my.class.annotated.with.SpringBootApplication&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextAttribute&lt;/param-name&gt;
              &lt;param-value&gt;org.springframework.web.context.WebApplicationContext.ROOT&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>So far I've seen suggestion to use </p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;spring.profiles.active&lt;/param-name&gt;
      &lt;param-value&gt;weblogic&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;init-param&gt;
      &lt;param-name&gt;spring.profiles.active&lt;/param-name&gt;
      &lt;param-value&gt;weblogic&lt;/param-value&gt;
  &lt;/init-param&gt;
  </code></pre>
  
  <p>in the DispatcherServlet configuration.</p>
  
  <p>I even tried configuring an ApplicationContextInitializer, but SpringBootContextLoaderListener provides his own initializer.</p>
  
  <p>Is there a proper way to accomplish what I want? I can't put weblogic configuration in main application.yml because that would break the embedded tomcat configuration we are using for development.</p>