Maven:如何将WAR文件部署到远程Tomcat服务器?
问题描述:
我正在使用Maven 3.0.3.我想在项目的验证阶段将WAR文件部署到运行Tomcat Manager应用程序的远程Tomcat 6服务器.我怎样才能做到这一点?我以为Cargo插件是拯救的关键,但是当我将其添加到pom.xml文件中时...
I'm using Maven 3.0.3. I want to deploy my WAR file to a remote Tomcat 6 server, running the Tomcat manager app, in the verify phase of my project. How can I do that? I thought the Cargo plugin was the key to salvation but when I added this to my pom.xml file ...
<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]
谢谢您的建议-戴夫
答
根据这些说明,然后根据您的错误消息,尝试删除<deployer>
标记下的<type>remote</type>
元素,然后重试.
According to these instructions and based on your error message, try removing the <type>remote</type>
element under the <deployer>
tag and try again.