1、在settings.xml里面的pluginGroups节点增加<pluginGroup>org.codehaus.cargo</pluginGroup>以便命令行调用,然后增加server
2、部署到本地Web容器
If you wish to use Jetty 5.x, you don't have to specify <containerId>
nor <type>
in the <container>
element because Jetty 5x is Cargo's default container.
2.1、standalone模式
在standalone模式,Cargo会从Web容器的安装目录复制一份配置(conf目录)到用户指定的目录,然后在此基础上部署应用,每次重新构建的时候,用户指定目录都会被清空,所有配置被重新生成。
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<!--
cargo.hostname the remote host name or ip address
-->
<configuration>
<container>
<containerId>tomcat7x</containerId>
<!-- Tomcat容器的主目录 -->
<home>E:\workspace\richinfo\apache-tomcat\apache-tomcat-7.0.65</home>
<log>${project.build.directory}/cargo.log</log>
<output>${project.build.directory}/output.log</output>
</container>
<configuration>
<type>standalone</type>
<home>${project.build.directory}/tomcat7x</home>
<properties>
<!-- 更改监听端口 -->
<cargo.servlet.port>80</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
mvn cargo:run启动
2.2、existing模式
在existing模式下,用户需要指定现有的web容器配置目录,然后Cargo会直接使用这些配置并将应用部署到其对应的位置。相当于替代人为部署到web容器中,即使web容器处于未运行状态。
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<home>E:\workspace\richinfo\apache-tomcat\apache-tomcat-7.0.65</home>
<log>${project.build.directory}/cargo.log</log>
<output>${project.build.directory}/output.log</output>
</container>
<configuration>
<type>existing</type>
<home>E:\workspace\richinfo\apache-tomcat\apache-tomcat-7.0.65</home>
</configuration>
</configuration>
</plugin>
运行cargo:run之后在对应的tomcat的webapps目录下能够看到被部署的应用。
3、 部署到远程Web容器
注意在远程部署模式下, Contai