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包
相关文章
相关标签/搜索