標籤:
保證tomcat7配置完成。安裝m2Eclipse外掛程式;
下面是具體的使用方法:
- Tomcat7的使用者及許可權配置:在conf目錄下,找到tomcat-users.xml,添加manager許可權的使用者。這裡我把所用的許可權都添加給admin使用者了,具體代碼如下:
<role rolename="admin-gui"/><role rolename="admin-script"/><role rolename="manager-gui"/><role rolename="manager-script"/><role rolename="manager-jmx"/><role rolename="manager-status"/><user username="admin" password="password" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
- Maven的Server的配置:在Maven的安裝路徑找到conf目錄下的setting.xml檔案,在<servers>節點中添加tomcat7下配置的使用者資訊(id可以任意填寫,但username和password必須和步驟1一致)
<server> <id>tomcat7</id> <username>admin</username> <password>password</password></server>
- 在Web項目的pom.xml檔案的<plugins>節點中,添加tomcat7的maven外掛程式,
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <!-- 注意此處的url --> <url>http://localhost:8080/manager/text</url> <server>tomcat7</server> <!-- 此處的名字必須和setting.xml中配置的ID一致--> <path>/mavenProject</path> <!-- 此處的名字是項目發布的工程名--> </configuration></plugin>
最後,只需要mvn tomcat7:redeploy就可以了(必須事先啟動tomcat伺服器)
run run configration
Maven Eclipse tomcat7 整合 (2) maven自動部署到tomcat7