首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven cargo plugin嵌入式tomcat 7配置

Maven cargo plugin嵌入式tomcat 7配置
EN

Stack Overflow用户
提问于 2012-01-11 22:30:00
回答 1查看 2.6K关注 0票数 0

我想知道maven cargo插件运行嵌入式tomcat 7进行集成测试所需的最低配置是什么,请指教,谢谢。

EN

回答 1

Stack Overflow用户

发布于 2012-01-31 20:36:30

这应该足够了(指定端口是可选的,更改url以获得不同版本的tomcat7):

代码语言:javascript
复制
        <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.2.0</version>
    <!-- minimal configuration to let adb run (mvn package org.codehaus.cargo:cargo-maven2-plugin:run) in a local tomcat -->
    <configuration>
      <container>
        <containerId>tomcat7x</containerId>
        <zipUrlInstaller>
          <url>http://a-inet01:8100/apache-tomcat-7.0.25.zip</url>
        </zipUrlInstaller>
      </container>
      <configuration>
        <properties>
          <cargo.servlet.port>1718</cargo.servlet.port>
        </properties>
      </configuration>
    </configuration>
  </plugin>

然后mvn包org.codehaus.cargo:cargo-maven2-plugin:run (在包含“war”包的mavenproject上)将创建war,从给定的url下载tomcat,启动并部署war。如果你使用start,容器会在maven结束时停止(这是你在集成测试中会用到的):如果你想自动启动cargo,而不是补足:

代码语言:javascript
复制
            <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <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>
            <configuration>
                [Cargo plugin configuration goes in here]
            </configuration>
        </plugin>

刚从cargo maven docu (http://cargo.codehaus.org/Starting+and+stopping+a+container)复制过来。这将在“集成测试”之前启动容器,并在测试之后停止它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8820977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档