首页 文章

使用Cargo with Maven远程部署WAR而无需HOT部署

提问于
浏览
4

我们在构建服务器上使用Cargo with Maven将WAR文件从我们的构建服务器远程部署到内部QA服务器进行测试 .

我们当前的项目POM如下所示,适用于热部署 .

问题是,我们希望Cargo插件停止Tomcat实例,部署新的WAR,然后启动Tomcat,而不是热部署 . 有没有办法改变POM来管理这种情况?

我们的Maven构建定义为:

mvn clean deploy ... cargo:redeploy

POM中的货物插件设置:

<plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <configuration>
                            <container>
                                <containerId>tomcat7x</containerId>
                                <type>remote</type>
                                <systemProperties>
                                    <cargo.jvmargs>-XX:MaxPermSize=256M -Xmx1024m</cargo.jvmargs>
                                </systemProperties>
                            </container>
                            <configuration>
                                <type>runtime</type>
                                <properties>
                                    <cargo.hostname>qa-server</cargo.hostname>
                                    <cargo.servlet.port>8080</cargo.servlet.port>
                                    <cargo.tomcat.manager.url>http://qa-server:8080/manager</cargo.tomcat.manager.url>
                                    <cargo.remote.username>username</cargo.remote.username>
                                    <cargo.remote.password>pass</cargo.remote.password>
                                </properties>
                            </configuration>
                            <deployer>
                                <type>remote</type>
                                <deployables>
                                    <deployable>
                                        <groupId>com.ourcompany</groupId>
                                        <artifactId>myapp-artifactId</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>latest</context>
                                        </properties>
                                    </deployable>
                                </deployables>
                            </deployer>
                        </configuration>
                    </plugin>

2 回答

  • 0

    我们遇到了Cargo的困难 . 过了一会儿,tomcat卡住了,不会重启 . 货物不允许启动/停止tomcat .

    所以我们最终做的就是放弃货物并使用脚本在远离我们的jenkins机器的情况下重新启动tomcat . 我们还在用于部署战争的集成机器上共享一个文件夹 . 我们还使用maven程序集插件来处理conf文件和文件夹 .

  • 4

    如何在build.xml文件中调用cleanTomcat ant任务并遵循以下流程:

    #1. stop, clean container, start
    mvn cargo:stop 
        antrun:run <<<<<<< build.xml file to clean +war +warUnpacked +context.xml
        cargo:start
    
    #2. deploy your webapp
    mvn cargo:deploy
    

    关于unludo之前的响应,在服务器之间共享文件夹是提高部署阶段速度的好方法 .

    您也可以使用maven-clean-plugin(是mvn clean但具有额外配置)清除java项目之外的目录,即删除tomcat容器中需要删除的内容 .

相关问题