Reprinted from: http://my.oschina.net/angel243/blog/178554
I used to use maven very little in my project, and recently I learned about Maven, which is really a very powerful project building tool, for the definition and version of dependent packages, and for centralized management of dependencies (central warehouse). (Forgive my fuss, though Maven came out for a long time, but the younger brother just contacted), However, when developing a Web project, it is necessary to manually deploy to the Web server (TOMCAT7), if it can be automatically deployed to the Web server, instead of having to manually copy the target compiled war package to tomcat every time.
Here are the specific ways to use it:
1, TOMCAT7 Users and Permissions configuration: In the Conf directory, find Tomcat-users.xml, add Manager permissions of the user. Here I have used the permissions are added to the Admin user, the specific code is as follows:
<rolerolename= "Admin-gui"/><rolerolename= "Admin-script"/><rolerolename= "Manager-gui"/><rolerolename= "Manager-script"/><rolerolename= "MANAGER-JMX"/><rolerolename= "Manager-status"/><Userusername= "Admin"Password= "Password"Roles= "Manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
2, MAVEN server configuration: In the MAVEN installation path to find the Conf directory Setting.xml file, in the <servers> node to add TOMCAT7 configuration of user information (ID can be arbitrarily filled out, However, username and password must be consistent with step 1):
<Server> <ID>Tomcat7</ID> <username>Admin</username> <Password>Password</Password></Server>
3. In the <plugins> node of the Web project's Pom.xml file, add the TOMCAT7 maven plugin,
<plugin> <groupId>Org.apache.tomcat.maven</groupId> <Artifactid>Tomcat7-maven-plugin</Artifactid> <version>2.1</version> <Configuration> <!--Note the URL here - <URL>Http://localhost:8080/manager/text</URL> <Server>Tomcat7</Server> <!--the name here must match the ID configured in Setting.xml - <Path>/mavenproject</Path> <!--The name here is the project name - </Configuration></plugin>
4, finally, only need to MVN Tomcat7:deploy (you must start the Tomcat server beforehand)
MAVEN implements direct deployment of Web projects to TOMCAT7 (RPM)