title: Works without maven profile, bug with
body: <p>Here is my problem,</p>
  
  <p>So here is my profile in pom.xml : </p>
  
  <pre><code>&lt;profiles&gt;
      &lt;profile&gt;
              &lt;id&gt;dev&lt;/id&gt;
              &lt;activation&gt;
                  &lt;property&gt;
                      &lt;name&gt;environment&lt;/name&gt;
                      &lt;value&gt;dev&lt;/value&gt;
                  &lt;/property&gt;
              &lt;/activation&gt;
          &lt;/profile&gt;
  
          &lt;profile&gt;
              &lt;id&gt;prod&lt;/id&gt;
              &lt;activation&gt;
                  &lt;property&gt;
                      &lt;name&gt;environment&lt;/name&gt;
                      &lt;value&gt;prod&lt;/value&gt;
                  &lt;/property&gt;
              &lt;/activation&gt;
          &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>When I use this context.xml, my application works perfectly :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jd="http://www.springframework.org/schema/jdbc"
  xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:sws="http://www.springframework.org/schema/web-services"
  xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
      http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3-0.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
  
  &lt;context:component-scan base-package="net.xxx.xxx.dao" /&gt;       
  
    &lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
              &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
              &lt;property name="url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:essmh" /&gt;
              &lt;property name="username" value="*****" /&gt;
              &lt;property name="password" value="*****" /&gt;
        &lt;/bean&gt;
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt;
          &lt;/property&gt;
          &lt;property name="persistenceUnitName" value="carfleetPersistenceUnit" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven /&gt;    
  &lt;/beans&gt;    
  </code></pre>
  
  <p>But I want to be able to change my <code>dataSource</code> according if I'm in production or in development. </p>
  
  <p>So here is what I've got now:</p>
  
  <pre><code> &lt;beans profile="dev"&gt;
    &lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
              &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
              &lt;property name="url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:dev" /&gt;
              &lt;property name="username" value="*****" /&gt;
              &lt;property name="password" value="*****" /&gt;
        &lt;/bean&gt;   
  &lt;/beans&gt;
  
  &lt;beans profile="prod"&gt;
    &lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
              &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
              &lt;property name="url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1522:prod" /&gt;
              &lt;property name="username" value="*****" /&gt;
              &lt;property name="password" value="*****" /&gt;
        &lt;/bean&gt;
  &lt;/beans&gt;
  
  &lt;beans profile="dev, prod"&gt;
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /&gt;
          &lt;/property&gt;
          &lt;property name="persistenceUnitName" value="carfleetPersistenceUnit" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
          &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>I check by using <code>mvn -e -P prod help:active-profiles</code> that the profile <code>prod</code> is active in every package and it is. But at the end, it doesn't work and I get the Error :</p>
  
  <p><code>Caused by : org.springframework.beans.factory.NoSuchBeanDefinitionException : No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0.</code></p>
  
  <p>For sure the error is there, because that's the only changed to go from "application is working" to "application has errors". </p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I now understand that I confused Spring profile and Maven profile, but I still, want to link the 2 of them.
  So for this, I put properties in my pom.xml > profiles :</p>
  
  <pre><code>&lt;profiles&gt;
      &lt;profile&gt;
              &lt;id&gt;dev&lt;/id&gt;
              &lt;properties&gt; 
                  &lt;environment&gt;dev&lt;/environment&gt; 
              &lt;/properties&gt;
          &lt;/profile&gt;
  
          &lt;profile&gt;
              &lt;id&gt;prod&lt;/id&gt;
              &lt;properties&gt; 
                  &lt;environment&gt;prod&lt;/environment&gt; 
              &lt;/properties&gt;
          &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>And I add in my web.xml :</p>
  
  <pre><code>&lt;context-param&gt;
  &lt;param-name&gt;spring.profiles.active&lt;/param-name&gt;
  &lt;param-value&gt;${environment}&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>When I hardcode <code>${environment}</code> for <code>dev</code> or <code>prod</code> it works perfectly.
  But when I want to be able to switch from Maven : <code>clean -Pprod  package tomcat7:redeploy</code>
  I got the following issue : </p>
  
  <pre><code>IllegalArgumentException : Could not resolve placeholder 'environment' in string value "${environment}`
  </code></pre>