Cargo-maven2-plugin插件自动部署

本文介绍了如何使用Cargo-maven2-plugin插件进行自动部署,包括在settings.xml中配置pluginGroup和server,以及在Jetty和Tomcat中的使用。详细讲解了standalone和existing两种模式的区别,并提到了在Tomcat中添加角色和用户以避免403错误。此外,还对比了cargo:start和cargo:run命令的不同。参考了《Maven实战》及相关官方文档。
摘要由CSDN通过智能技术生成

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值