title: Run Maven webapp on server from Eclipse with properties injection from profile
body: <p>I use Eclipse &amp; Maven to develop a Spring + Hibernate webapp, and in my <code>pom.xml</code> I have several profiles with different properties that I inject to a <code>.properties</code> file. This file is used in <code>applicationContext.xml</code> to configure Spring, and when I want to launch the application, I'm obliged to deploy it on a running tomcat outside Eclipse. Here is some parts of my code :</p>
  
  <p><strong>pom.xml :</strong></p>
  
  <pre><code>...
  &lt;profile&gt;
      &lt;id&gt;development&lt;/id&gt;
      &lt;properties&gt;
          &lt;db.driverClassName&gt;com.mysql.jdbc.Driver&lt;/db.driverClassName&gt;
          &lt;db.name&gt;mydbname&lt;/db.name&gt;
          &lt;db.params&gt;?createDatabaseIfNotExist=true&amp;amp;amp;useUnicode=true&amp;amp;amp;characterEncoding=utf-8&lt;/db.params&gt;
  
          &lt;hibernate.hbm2ddl.auto&gt;update&lt;/hibernate.hbm2ddl.auto&gt;
          &lt;hibernate.show_sql&gt;true&lt;/hibernate.show_sql&gt;
  
          &lt;log4j.spring.level&gt;WARN&lt;/log4j.spring.level&gt;
          &lt;log4j.hibernate.level&gt;WARN&lt;/log4j.hibernate.level&gt;
      &lt;/properties&gt;
  &lt;/profile&gt;
  ...
  </code></pre>
  
  <p><strong>application.properties :</strong></p>
  
  <pre><code>...
  # JDBC Information
  # Some properties are in my .m2/settings.xml
  jdbc.driver.classname=${db.driverClassName}
  jdbc.url=${db.url}/${db.name}${db.params}
  jdbc.user=${db.username}
  jdbc.pass=${db.password}
  ...
  </code></pre>
  
  <p><strong>applicationContext.xml :</strong></p>
  
  <pre><code>...
  &lt;!-- JDBC Data Source --&gt;
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close"&gt;
      &lt;property name="driverClassName" value="${jdbc.driver.classname}" /&gt;
      &lt;property name="url" value="${jdbc.url}" /&gt;
      &lt;property name="username" value="${jdbc.user}" /&gt;
      &lt;property name="password" value="${jdbc.pass}" /&gt;
  &lt;/bean&gt;
  ...
  </code></pre>
  
  <p>Using the Tomcat7 Maven plugin, deployment via <code>mvn tomcat7:deploy</code> works fine, but when I choose <em>"Right-click > Run as > Run on server"</em>, I get a lot of exceptions related to the placeholders :</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'db.driverClassName' in string value "${db.driverClassName}"
      at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173)
      at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:161)
      at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125)
      at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:180)
      at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:145)
      at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:167)
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282)
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveValue(BeanDefinitionVisitor.java:204)
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitPropertyValues(BeanDefinitionVisitor.java:141)
      at org.springframework.beans.factory.config.BeanDefinitionVisitor.visitBeanDefinition(BeanDefinitionVisitor.java:82)
      at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:206)
      ... 17 more
  </code></pre>
  
  <p>How can I run my project in the Eclipse embedded Tomcat and get the logs in the console instead of in <code>logs/catalina.out</code> ?</p>
  
  <p>Thanks for help.</p>