【问题标题】:Maven cargo plugin embedded tomcat 7 configurationMaven cargo plugin 内嵌 tomcat 7 配置
【发布时间】:2012-02-07 21:49:51
【问题描述】:

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

【问题讨论】:

标签: jakarta-ee maven-2 tomcat7 maven-cargo


【解决方案1】:

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

        <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 package org.codehaus.cargo:cargo-maven2-plugin:run (在带有包装“war”的 mavenproject 上)将创建战争,从给定的 url 下载 tomcat,启动它并部署战争。如果你使用 start 容器在 maven 完成后停止(这个你将在集成测试中使用): 如果您想自动启动货物而不是补充:

            <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 文档 (http://cargo.codehaus.org/Starting+and+stopping+a+container) 复制。这将在“集成测试”之前启动容器并在测试之后停止它。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2013-01-14
  • 2011-09-20
  • 2011-10-22
  • 2019-10-13
  • 1970-01-01
  • 2013-06-03
  • 2015-04-10
  • 2012-07-25
相关资源
最近更新 更多