title: How to override spring property param with Tomcat?
body: <p>I have defined property in <code>Spring</code> application.</p>
  
  <pre><code>@Configuration
  public class WebappConfiguration {
  
      @Value("${ext.storage.path}")
      private String extDirectoryPath;
  
      public String getExtDirectoryPath() {
          return extDirectoryPath;
      }
  }
  </code></pre>
  
  <p>Default value for <code>ext.storage.path</code> property is defined in <code>application.properties</code> file.</p>
  
  <p><em>application.properties</em></p>
  
  <pre><code>ext.storage.path=/home/user/ext/
  </code></pre>
  
  <p>When I deploy <code>WAR</code> to tomcat with VM options <code>-Dext.storage.path=/var/webapp-data/</code>, this value is loaded successfully. But I would like to load property values more smarter from context files for every environment.</p>
  
  <p>So I deploy the <code>WAR</code> to <code>ROOT</code> of Tomcat, name of WAR file is <code>ROOT.war</code> and it is exploded to <code>ROOT</code> directory. I created <code>context</code> file on path <code>{CATALINA_BASE}/Catalina/localhost/ROOT.xml</code> with following content.</p>
  
  <p><em>ROOT.xml</em></p>
  
  <pre><code>&lt;Context 
          docBase="/opt/webapp-tomcat/webapps/ROOT.war"
          path=""
          reloadable="true"&gt;
  
          &lt;Parameter name="ext.storage.path" value="file:/var/webapp-data/" override="true"/&gt;
  
  &lt;/Context&gt;
  </code></pre>
  
  <p>Unfortunately, the param is not loaded according to the way, it has default value from <code>application.properties</code>.</p>
  
  <p><strong>EDIT:</strong>
  After a little investigation, I put the <code>Parameter</code> into main <code>context.xml</code> file of Tomcat and the value is overridden.</p>
  
  <pre><code>&lt;Parameter name="ext.storage.path" value="file:/var/webapp-data/" override="true"/&gt; 
  </code></pre>