One-click deployment of Java web projects with maven greatly improves work efficiency.
1. In the configuration file of tomcat7 (TOMCAT_HOME/conf/tomcat_users.xml), add the following:
<role rolename="manager-gui"/> <role rolename="manager-script"/> --Note: You need to ensure that the role is applicable <user username="admin" password="******" roles="manager-gui, manager-script"/>
2. Set in the maven file setting.xml:
</servers> <server> <id>test</id> --Note: be consistent with the server name in the pom.xml file <username>admin</username> --Note: keep the same as the username and password in tomcat-users.xml <password>*****</password> </server> </servers>
3. Add the following to the pom.xml file in the project:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <server>test</server> --Note: be consistent with the server name in the pom.xml file <url>http://mydomain:8080/manager/text</url>; --Note: This link applies to the manager-script set in tomcat7 <path>/myweb</path> --注释:artifactId=myweb </configuration> </plugin>
4. RUN AS, Goals:
tomcat7:redeploy