<plugin>But it doesn't work for tomcat7 server. After googling, I found a new plugin for deploying in tomcat7: http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/snapshot-test.html And so here's how I use the new plugin: 1.) Add the ff lines in your maven's settings.xml, usually found in %user%/.m2 folder.
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<server>MyServer</server>
<path>/myApp</path>
</configuration>
</plugin>
<server>2.) Modify tomcat's 7 tomcat-users.xml file, which can be found inside "%tomcat_installation%/config, and add the ff lines:
<id>TomcatServer</id>
<username>admin</username>
<password>admin</password>
</server>
<role rolename="manager-gui"/>Take note that manager roles has been broken down into 4 roles as you can see. 3.) In your pom.xml file, add these repository and plugin repository:
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
<repositories>4.) Then, what I usually does is to create a development profile where I can set the deployment mechanism in my local machine, in this case using the tomcat7 maven plugin:
<repository>
<id>people.apache.snapshots</id>
<url>http://repository.apache.org/content/groups/snapshots-group/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Apache Snapshots</name>
<url>http://repository.apache.org/content/groups/snapshots-group/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<profiles>Note that the url needs the additional /html, as it's updated by apache, otherwise you will get the error: "403 access denied" 5.) You can now invoke the tomcat7 deploy command as documented by the link in the top of this writing.
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>TomcatServer</server>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
mvn tomcat7:deploy