2011-12-07 248 views
2

我使用的是Maven 3.0.3。我想在我的项目的验证阶段将我的WAR文件部署到远程Tomcat 6服务器,运行Tomcat管理器应用程序。我怎样才能做到这一点?我以为货物插件是关键的救赎,但是当我将此添加到我的pom.xml文件...Maven:如何将我的WAR文件部署到远程Tomcat服务器?

 <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] 

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

+0

根据您的配置,您已经下载并启动了一个Tomcat,并将您的战争归档部署到该Tomcat(预集成测试)中,此外您正尝试将您的战争部署到远程tomcat(验证)中。这是否有充分的理由?如果您调用mvn验证预集成测试,集成测试,验证是在这种情况下运行的阶段。 – khmarbaise

回答

2

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

+0

我根据您的建议删除了“远程”。虽然这确实使错误消失了,但WAR文件并未部署到Tomcat服务器,即使运行具有相应属性(例如-Dtomcat.manager.url =)的“mvn clean verify”导致成功。当我故意输入一个糟糕的tomcat管理员URL或密码时,我还有什么问题,我仍然获得了构建成功。 – Dave

+0

顺便说一句,我继续接受,因为它似乎像我的问题是多种配置,但如果你有任何其他想法,绝对回应评论。谢谢, - – Dave

相关问题