tomcat - 远程服务器上的 Cargo Maven

标签 tomcat cargo-maven2-plugin

我正在尝试使用 cargo maven 插件在远程服务器上运行 war ,但我得到: [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.6.4:start (start-container) on project portnet: Only local containers can be started -> [帮助 1]

我有以下配置:

          <plugin>
             <groupId>org.codehaus.cargo</groupId>
             <artifactId>cargo-maven2-plugin</artifactId>
             <version>1.6.4</version>
             <configuration>
             <wait>false</wait>
               <container>
                  <containerId>tomcat8x</containerId>
                  <type>remote</type>                 
               </container>

               <configuration>
                  <type>runtime</type>
                     <files>
                        <copy>
                           <file>C:\apache-tomcat-8.5.20\conf\tomcat-users.xml</file>
                           <tofile>conf/tomcat-users.xml</tofile>
                           <configfile>true</configfile>
                           <overwrite>true</overwrite>
                        </copy>
                     </files>
                     <properties>
                        <cargo.hostname>remoteserver</cargo.hostname>
                        <cargo.servlet.port>8180</cargo.servlet.port>
                        <cargo.remote.username>user</cargo.remote.username>
                        <cargo.remote.password>passw</cargo.remote.password>                           <cargo.tomcat.manager.url>http://localhost:8180/manager</cargo.tomcat.manager.url>
                </properties>
                </configuration>

            <deployer>
                <type>remote</type>                 
            </deployer>

            <deployables>
                <deployable>
                   <type>war</type>
                   <properties>
                          <context>/portnet</context>
                    </properties>    
            </deployable>
            </deployables>

        </configuration>

            <executions>
              <!-- start server before integration tests -->
              <execution>
                <id>start-container</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <!-- stop server after integration tests -->
              <execution>
                <id>stop-container</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
    </plugins>

最佳答案

如果你想使用远程服务器,那么你可以使用这两个 Cargo 目标:

  • deploy - 此目标用于将定义的可部署对象部署到远程服务器。
  • undeploy - 此目标用于从远程服务器取消部署已定义的可部署项。

目标 startstop可以仅用于本地容器 - 其生命周期由 Cargo Maven 插件直接控制的容器。

如果你替换<goal>start</goal>在您的配置中使用 <goal>deploy</goal><goal>stop</goal><goal>undeploy</goal>那么你应该摆脱这个错误。

关于tomcat - 远程服务器上的 Cargo Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46215760/

相关文章:

maven - Cargo Maven Tomcat NoInitialContextException 当我已经有了 Context

java - 为 servlet 分配异常 - JAVA 中的 Web 编程

java - tomcat上的logback配置

java - 无法从 Java servlet 访问 Tomcat 服务器

java - 使用与 Tomee 提供的不同版本的 jar

java - 是否可以在 Web 应用程序中运行 cron 作业?

java - org.codehaus.cargo.container.ContainerException : Cannot create deployable