title: Spring boot on Tomcat with external configuration
body: <p>I can't find an answer to this question on stackoverflow hence im asking here so I could get some ideas.</p>
  
  <p>I have a Spring Boot application that I have deployed as a war package on Tomcat 8. I followed this guide <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html" rel="nofollow noreferrer">Create a deployable war file</a> which seems to work just fine.</p>
  
  <p>However the issue I am currently having is being able to externalize the configuration so I can manage the configuration as puppet templates.</p>
  
  <p>In the project what I have is,</p>
  
  <pre><code>src/main/resources
                    -- config/application.yml
                    -- config/application.dev.yml
                    -- config/application.prod.yml
                    -- logback-spring.yml
  </code></pre>
  
  <p>So how can I possibly load <code>config/application.dev.yml</code> and <code>config/application.prod.yml</code> externally and still keep <code>config/application.yml</code> ? (contains default properties including <code>spring.application.name</code>)</p>
  
  <p>I have read that the configuration is load in this order,</p>
  
  <ol>
  <li>A /config subdirectory of the current directory. </li>
  <li>The current directory </li>
  <li>A classpath /config package </li>
  <li>The classpath root</li>
  </ol>
  
  <p>Hence I tried to load the configuration files from <code>/opt/apache-tomcat/lib</code> to no avail.</p>
  
  <p><strong>What worked so far</strong></p>
  
  <p>Loading via <code>export CATALINA_OPTS="-Dspring.config.location=/opt/apache-tomcat/lib/application.dev.yml"</code> </p>
  
  <p>however <strong>what I would like to know is</strong>,</p>
  
  <ol>
  <li>Find out why loading via <code>/opt/apache-tomcat/lib</code> classpath doesn't work.</li>
  <li>And is there a better method to achieve this ?</li>
  </ol>