maven實現tomcat的遠程部署

利用maven的插件和tomcat自身提供的部署功能來實現遠程部署。 shell

首先在pom文件裏設置插件: tomcat

<plugin>  
    <groupId>org.codehaus.mojo</groupId>  
    <artifactId>tomcat-maven-plugin</artifactId>  
    <configuration>  
        <url>http://localhost:8080/manager</url>  
        <server>testMVN</server>  
        <path>/mycontext</path>  
    </configuration>  
</plugin>

而後在maven的settings.xml裏配置 maven

<servers>
	<server>
		<id>testMVN</id>
		<username>marshal</username>
		<password>password</password>
	</server>
</servers>



以上需注意兩點:tomcat插件的Url爲deploy回調路徑,須要用戶名和密碼,在tomcat-user.xml加一個就行;<server>的名字要和settings.xml裏的<id>一致。


1.mvn tomcat:deploy. 發佈  (若是已經存在則發佈不了)



2.mvn tomcat:redeploy. 從新發布 (會替換已存在的項目)



3.mvn tomcat:undeploy 撤銷部署
4.mvn tomcat:start    啓動項目
5.mvn tomcat:stop     中止項目
6.mvn war:exploded tomcat:exploded 展開war包
相關文章
相關標籤/搜索