使用Maven Cargo 插件管理Tomcat7的远程和本地部署

使用Maven Cargo 插件管理Tomcat6的部署原文:[url]http://jdonee.iteye.com/blog/774387[/url]
参考文档:
[color=red][b]Apache Maven Cargo deploy with Tomcat 7[/b][/color]
[url]http://www.waltercedric.com/index.php?option=com_content&view=article&id=1906:&catid=129&Itemid=332[/url]


tomcat-users.xml,必须存在admin账户:
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="manager-status"/>
<role rolename="manager-jmx"/>
<role rolename="manager-gui"/>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<user username="admin" password="admin" roles="admin,admin-gui,manager,manager-gui,manager-script,manager-status,manager-jmx"/>
</tomcat-users>



tomcat7远程部署: 前提,这个tomcat已经存在并运行。
            <plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>http://xxx.xxx.xxx:8080/manager/text/</cargo.remote.uri>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>xxx</groupId>
<artifactId>yyy</artifactId>
<type>war</type>
<properties>
<context>/my_web_context_path</context>
</properties>
</deployable>
</deployables>
</configuration>
<executions>
<!-- 打包的时候顺便部署-->
<execution>
<phase>package</phase>
<goals>
<!--<goal>deployer-undeploy</goal>-->
<goal>deployer-redeploy</goal>
</goals>
</execution>
</executions>
</plugin>

deployer是部署时的相关配置,这个context是用来声明工程部署后的上下文,也就是主机地址后面的一级目录位置。这个设置在maven构建中还是很必要的。因为maven默认打出 的war包是工程名+版本号,部署时如果不设置这里的context,那上下文就变成了工程名+版本号的形式。这会使访问变得很不方便。注意,即使你通过修改war插件中的warName也是不能达到这个 目的,因为cargo认定的默认war包名就是工程名+版本号的形式。也可以利用finalName来制定

如果配置了exceutions的话,就是maven的周期(上面是package周期)的时候出发,
命令:[b][color=darkblue]mvn package[/color][/b]
否则单独运行:[b][color=darkblue]
mvn cargo:deployer-undeploy //如果先存在已经部署的,就先执行这句,卸载掉原先部署的。
mvn cargo:deployer-deploy
或者直接执行
mvn cargo:deployer-redeploy
[/color][/b]
注意:
<groupId>xxx</groupId>
<artifactId>yyy</artifactId>

这里应该跟pom定义的一致,如果打包得到war的文件不是按照pom的规则来,那么可能会找不到war文件。


[color=red][size=large]本地和远程部署的配置参考,未测试[/size][/color]
本地
            <plugin>              
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<home>F:\apache-tomcat-6.0.18</home>
</container>
<configuration>
<type>existing</type>
<home>F:\apache-tomcat-6.0.18</home>
</configuration>
</configuration>
</plugin>


远程
            <plugin>              
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote </type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
<cargo.tomcat.manager.url>
http://172.31.36.214:8080/manager
</cargo.tomcat.manager.url>
</properties>
</configuration>
</configuration>

</plugin>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值