1、在项目下pom.xml文件中的<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>tomcat</server>
- </configuration>
- </plugin>
2、在maven的settings.xml中加入:
- <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>
- <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>
3、打开tomcat的安装目录的 conf/tomcat-users.xml,添加以下内容:
- <rolerolenamerolerolename="manager-gui"/>
- <userusernameuserusername="admin"password="admin"roles="manager-gui"/>
4、在maven的settings.xml中加入:
- <server>
- <id>tomcat</id>
- <username>admin</username>
- <password>admin</password>
- </server>
5、使用mvn tomcat7:deploy即可部署。