一尘不染

Maven:如何将WAR文件部署到远程Tomcat服务器?

tomcat

我正在使用Maven 3.0.3。我想在项目的验证阶段将WAR文件部署到运行Tomcat Manager应用程序的远程Tomcat
6服务器。我怎样才能做到这一点?我以为Cargo插件是拯救的关键,但是当我将其添加到pom.xml文件中时…

        <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <configuration>
                <container>
                    <containerId>tomcat${tomcat.major}x</containerId>
                    <zipUrlInstaller>
                        <url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
                        <downloadDir>${project.build.directory}/downloads</downloadDir>
                        <extractDir>${project.build.directory}/extracts</extractDir>
                    </zipUrlInstaller>
                    <output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
                    <log>${project.build.directory}/cargo.log</log>
                </container>
                <configuration>
                    <home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
                    <properties>
                        <cargo.logging>high</cargo.logging>
                        <cargo.servlet.port>${tomcat.servlet.port}</cargo.servlet.port>
                        <cargo.tomcat.ajp.port>${tomcat.ajb.port}</cargo.tomcat.ajp.port>
                    </properties>
                </configuration>
            </configuration>
            <executions>
                <execution>
                    <id>start-container</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                        <goal>deploy</goal>
                    </goals>
                    <configuration>
                        <deployer>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>war</type>
                                    <pingURL>http://localhost:${tomcat.servlet.port}/${project.artifactId}</pingURL>
                                    <pingTimeout>30000</pingTimeout>
                                    <properties>
                                        <context>${project.artifactId}</context>
                                    </properties>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-container</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
                <!--  In the verify phase, deploy the app to a Tomcat instance.  We
                      require that the properties "tomcat.manager.url", "tomcat.username", and
                      "tomcat.password" be defined. 
                 -->
                <execution>
                    <id>deploy-to-remote-tomcat</id>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                    <phase>verify</phase>
                    <configuration>
                        <container>
                            <containerId>tomcat${tomcat.major}x</containerId>
                            <type>remote</type>
                        </container>
                        <configuration>
                            <type>runtime</type>
                            <properties>
                                <cargo.tomcat.manager.url>${tomcat.manager.url}</cargo.tomcat.manager.url>
                                <cargo.remote.username>${tomcat.username}</cargo.remote.username>
                                <cargo.remote.password>${tomcat.password}</cargo.remote.password>
                            </properties>
                        </configuration>
                        <deployer>
                            <type>remote</type>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>${project.packaging}</type>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                </execution> 
            </executions>
        </plugin>

我得到错误

Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.1.3:redeploy (deploy-to-remote-tomcat) on project myco-productplus-web: Execution deploy-to-remote-tomcat of goal org.codehaus.cargo:cargo-maven2-plugin:1.1.3:redeploy failed: Failed to create deployer with implementation class org.codehaus.cargo.container.tomcat.Tomcat6xRemoteDeployer for the parameters (container [id = [tomcat6x]], deployer type [remote]). argument type mismatch -> [Help 1]

感谢您的任何建议,-戴夫


阅读 333

收藏
2020-06-16

共1个答案

一尘不染

根据这些说明并根据您的错误消息,尝试删除标签<type>remote</type>下的元素,<deployer>然后重试。

2020-06-16