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

时间:2011-12-07 21:26:56

标签: tomcat maven maven-2

我正在使用Maven 3.0.3。我想在项目的验证阶段将我的WAR文件部署到运行Tomcat管理器应用程序的远程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]

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

1 个答案:

答案 0 :(得分:2)

根据these instructions并根据您的错误消息,尝试删除<type>remote</type>标记下的<deployer>元素,然后重试。