maven外掛之tomcat7-maven-plugin
阿新 • • 發佈:2018-12-02
tomcat7-maven-plugin外掛的pom.xml依賴為:
<dependency> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> </dependency>
一:直接執行webapp專案
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/taobao</path> <port>9090</port> <uriEncoding>UTF-8</uriEncoding> </configuration> </plugin>
執行 mvn tomcat7:run
訪問 http://127.0.0.1:9090/taobao 就可以訪問
二:部署專案到tomcat
首先。在conf/tomcat-users.xml 檔案中面配置
<role rolename="manager-gui"/> <user username="admin" password="123456" roles="manager,manager-gui"/>
兩種方法部署
(1)
直接在pom.xml裡面配置外掛
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/taobao</path> <url>http://127.0.0.1:8080/manager/text</url> <username>admin</username> <password>123456</password> </configuration> </plugin>
(2)
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <uriEncoding>UTF-8</uriEncoding> <url>http://127.0.0.1:8080/manager/text</url> <server>tomcat7</server> </configuration> </plugin>
然後,在settting.xml裡面加入
<server> <id>tomcat7</id> <username>admin</username> <password>123456</password> </server>
注意。上面的/manager/text不能是/manager/html,否則報403錯誤
最後,執行 mvn tomcat7:deploy就可以部署
訪問地址為:http://127.0.0.1:8080/taobao