Maven使用Cargo实现自动化部署
由于公司配置的垃圾台式机,根本就没法开发,开一个sts,跑一个内嵌的tomcat就卡出翔,测试每次想在我机器上测试,所以弄了下maven下使用Cargo实现自动化部署,这样就可以把本地的应用部署到远程服务器上去,省的垃圾电脑卡出翔。先在settings.xml里面的pluginGroups节点增加
<pluginGroup>org.codehaus.cargo</pluginGroup>以便命令行调用,然后增加server
<server>
<id>tomcat7x</id>
<username>admin</username> <password>password</password>
</server>
1.部署到本地Web容器
1.1 standalone模式
在standalone模式,Cargo会从Web容器的安装目录复制一份配置到用户指定的目录,然后在此基础上部署应用,每
次重新构建的时候,这个目录都会被清空,所有配置被重新生成 <plugin>
<groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.4.9</version> <configuration>
<home>/usr/local/devtools/apache-tomcat-7.0.55&l<container>
<containerId>tomcat7x</containerId>
t;/home>
<home>${project.build.directory}/tomcat7x</hom</container> <configuration>
<type>standalone</type>
e>
<properties>
<!-- 更改监听端口 -->
<cargo.servlet.port>8088</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
然后用mvn cargo:run启动,关于cargo:run于cargo:start有什么区别,后续会讲到。1.2 existing模式
在existing模式下,用户需要指定现有的web容器配置目录,然后Cargo会直接使用这些配置并将应用部署到其对应的位置<plugin>
<groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.4.9</version> <configuration>
<home>/usr/local/devtools/apache-tomcat-7.0.55&l<container>
<containerId>tomcat7x</containerId>
t;/home>
</container> <configuration>
<type>existing</type>