title: Using Maven settings.xml properties inside Spring context
body: <p>I've got a Maven <code>settings.xml</code> file in my <code>~/.m2</code> directory; it looks like this:</p>
  
  <pre><code>&lt;settings&gt;
      &lt;profiles&gt;
          &lt;profile&gt;
              &lt;id&gt;mike&lt;/id&gt;
              &lt;properties&gt;
                  &lt;db.driver&gt;org.postgresql.Driver&lt;/db.driver&gt;
                  &lt;db.type&gt;postgresql&lt;/db.type&gt;
                  &lt;db.host&gt;localhost&lt;/db.host&gt;
                  &lt;db.port&gt;5432&lt;/db.port&gt;
                  &lt;db.url&gt;jdbc:${db.type}://${db.host}:${db.port}/dbname&lt;/db.url&gt;
              &lt;/properties&gt;
          &lt;/profile&gt;
      &lt;/profiles&gt;
      &lt;activeProfiles&gt;
          &lt;activeProfile&gt;mike&lt;/activeProfile&gt;
      &lt;/activeProfiles&gt;
      &lt;servers&gt;
          &lt;server&gt;
              &lt;id&gt;server_id&lt;/id&gt;
              &lt;username&gt;mike&lt;/username&gt;
              &lt;password&gt;{some_encrypted_password}&lt;/password&gt;
          &lt;/server&gt;
      &lt;/servers&gt;
  &lt;/settings&gt;
  </code></pre>
  
  <p>I'd like to use these properties twice</p>
  
  <ul>
  <li>Once inside Maven's <code>integration-test</code> phase to set up and tear down my database.  Using Maven filtering, this is working perfectly.</li>
  <li>A second time when running my Spring application, which means I need to substitute these properties into my <code>servlet-context.xml</code> file during Maven's <code>resources:resources</code> phase.  For properties in the upper section of <code>settings.xml</code>, such as <code>${db.url}</code>, this works fine.  <strong>I cannot figure out how to substitute my database username and (decrypted) password into the Spring <code>servlet-context.xml</code> file.</strong></li>
  </ul>
  
  <p>The pertinent part of my <code>servlet-context.xml</code> file looks like:</p>
  
  <pre><code>&lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
      &lt;property name="driverClassName"&gt;&lt;value&gt;${db.driver}&lt;/value&gt;&lt;/property&gt;
      &lt;property name="url"&gt;&lt;value&gt;${db.url}&lt;/value&gt;&lt;/property&gt;
      &lt;property name="username"&gt;&lt;value&gt;${username}&lt;/value&gt;&lt;/property&gt;
      &lt;property name="password"&gt;&lt;value&gt;${password}&lt;/value&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The end goal here is for each developer to have their own Maven settings (and database on their own machine for integration testing)...And a similar setup on the Jenkins server.  We do not want to share a common username/password/etc.</p>