Don't believe everything you read on the Internet. You should remove src/main/webapp/WEB-INF/ from the resources list, it will just filter your web.xml to target/classes
Your maven-war-plugin
configuration just needs :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
Now, whether you build in Maven CLI or within Eclipse, you need to enable one of these profiles. In command line, you need to run
mvn clean package -Pdesenv
In Eclipse (assuming you're using the Luna Java EE distribution or more recent), you can enable the profile you want by pressing Ctrl+Alt+P
. If you enable desenv
, you'll see the filtered web.xml under target/m2e-wtp/web-resources/WEB-INF/
This is the file that will get published to your application server.
If you happen to enable both profiles at the same time, the latest profile listed in your pom.xml takes precedence.
Personally, I would remove the production profile and put the production properties in the default properties section of your pom.xml. That way, you always filter your web.xml with actual values and you'll have less chances of accidentally building and deploying your app with non-production settings.
And in order to enable the desenv
profile automatically in Eclipse, you can add the following activation rule :
<profile>
<id>desenv</id>
<!-- This profile is only activated when building in Eclipse with m2e -->
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<ambiente.producao>false</ambiente.producao>
</properties>
</profile>
More on dynamic resource filtering support in m2e-wtp here: https://developer.jboss.org/en/tools/blog/2011/05/03/m2eclipse-wtp-0120-new-noteworthy
And a screencast there :?http://screencast.com/t/hwodHqODBB
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…