title: How to use Maven Profile Name as a variable
body: <p>I need to build a war file that can call a JDBC connection depending on it's profile name.</p>
  
  <p>When I build with the dev profile, I need it to call the dev.properties file. And when I build with the prod profile, I need it to read from the prod.properties file.</p>
  
  <p>The idea that I came up with is to use the profile name as a variable somehow, but I can't figure out how to do it.</p>
  
  <p>POM.XML         </p>
  
  <pre><code>&lt;profile&gt;
      &lt;id&gt;dev&lt;/id&gt;
      &lt;activation&gt;
          &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
      &lt;/activation&gt;
      &lt;properties&gt;
          &lt;profile-id&gt;dev&lt;/profile-id&gt;
      &lt;/properties&gt;
  &lt;/profile&gt;
  &lt;profile&gt;
      &lt;id&gt;prod&lt;/id&gt;
      &lt;properties&gt;
          &lt;profile-id&gt;prod&lt;/profile-id&gt;
      &lt;/properties&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>servlet-context.xml</p>
  
  <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="location"&gt;
          &lt;value&gt;classpath:${profile-id}.properties&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;property name="dataSourceProperties"&gt;
      &lt;props&gt;                 
          &lt;prop key="url" &gt;${jdbc}&lt;/prop&gt;
          &lt;prop key="user"&gt;user&lt;/prop&gt;
          &lt;prop key="password"&gt;password&lt;/prop&gt;    
          &lt;prop key="implicitCachingEnabled"&gt;true&lt;/prop&gt;          
      &lt;/props&gt;
  &lt;/property&gt;
  </code></pre>