maven插件介紹之tomcat7-maven-plugin


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



maven技術交流 扣扣群  379165311。群里面會不定期分享一些maven文章和教程,歡迎大家增加


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM