在web項目的pom.xml中添加如下:
<build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <port>8080</port> <path>/web</path> <uriEncoding>UTF-8</uriEncoding> <finalName>web</finalName> <server>tomcat7</server> </configuration> </plugin> </plugins> </build>
然后項目右鍵--run as -- maven build -- 輸入參數 tomcat7:run。需要的構件下載完成后即可通過http://localhost:8080/web訪問項目


該插件可以遠程部署web項目,常用命令有:
| 命令 | 描述 |
| tomcat7:deploy | 部署一個web war包 |
| tomcat7:reload | 重新加載web war包 |
| tomcat7:start |
啟動tomcat |
| tomcat7:stop |
停止tomcat |
| tomcat7:undeploy |
停止一個war包 |
| tomcat7:run | 啟動嵌入式tomcat ,並運行當前項目 |
