1.在tomcat的conf/tomcat-users.xml中配置用戶,在tomcat-users節點中增加如下代碼:
<user username="tradesmatch" password="123456" roles="manager-gui,manager-script,manager-jmx,manager-status,admin- script,admin-gui"/>
2.在maven的settings.xml的servers節點增加如下代碼:
<server>
<id>tomcat7</id>
<username>tradesmatch</username>
<password>123456</password>
</server>
3.在pom.xml中的plugins節點增加如下配置:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <port>8080</port> <username>tradesmatch</username> <password>123456</password> <!--如果端口爲8080,url節點配置可以省略--> <url>http://localhost:8080/manager/text</url> <path>/${project.build.finalName}</path> <uriEncoding>UTF-8</uriEncoding> <finalName>${project.build.finalName}</finalName> <server>tomcat7</server> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> </plugin>
server節點的值要和maven的setting.xml的server節點的id值要一致,三個地方的用戶和密碼要一致。
4. eclipse 中的啓動配置,Goals中輸入:tomcat7:deploy,然後點擊run就進行web工程的部署。