Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将货物启动/停止目标绑定到Maven集成测试阶段时使用tomcat7x_Java_Tomcat_Maven_Pom.xml_Cargo - Fatal编程技术网

Java 将货物启动/停止目标绑定到Maven集成测试阶段时使用tomcat7x

Java 将货物启动/停止目标绑定到Maven集成测试阶段时使用tomcat7x,java,tomcat,maven,pom.xml,cargo,Java,Tomcat,Maven,Pom.xml,Cargo,我已经成功地在pom.xml中配置了Cargo,以便在执行“mvn Cargo:run”命令时启动tomcat7x。这是我使用的Cargo插件配置: <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.2.3</version>

我已经成功地在pom.xml中配置了Cargo,以便在执行“mvn Cargo:run”命令时启动tomcat7x。这是我使用的Cargo插件配置:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.2.3</version>
    <configuration>
        <containerId>tomcat7x</containerId>
        <containerUrl>http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.30/bin/apache-tomcat-7.0.30.zip</containerUrl>
    </configuration>
</plugin>

org.codehaus.cargo
cargo-maven2-plugin
1.2.3
tomcat7x
http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.30/bin/apache-tomcat-7.0.30.zip
这很好,而且效果很好。然而,我现在想将货物启动和停止目标绑定到maven集成前测试和集成后测试阶段。我使用与上面相同的配置,但也将执行添加到插件中,如下所示:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.2.3</version>
    <configuration>
        <containerId>tomcat7x</containerId>
        <containerUrl>http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.30/bin/apache-tomcat-7.0.30.zip</containerUrl>
    </configuration>
    <executions>
        <execution>
            <id>start-container</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
             <id>stop-container</id>
             <phase>post-integration-test</phase>
             <goals>
                 <goal>stop</goal>
             </goals>
        </execution>
    </executions>
</plugin>

org.codehaus.cargo
cargo-maven2-plugin
1.2.3
tomcat7x
http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.30/bin/apache-tomcat-7.0.30.zip
启动容器
预集成测试
开始
停止容器
整合后测试
停止
这也非常有效,在集成前测试中启动容器,执行集成测试,然后在集成后测试阶段停止容器。唯一的问题是它不是我配置的tomcat7x容器,它启动默认的Jetty容器,似乎忽略了我的tomcat7x配置

如何让这些执行与我配置的tomcat7x容器一起工作


谢谢。

我遇到了同样的问题,发现[这个答案][1]解决了它。[1] :我遇到了同样的问题,发现[这个答案][1]解决了它。[1]: