統合テストのために組み込みの tomcat 7 を実行するために maven cargo プラグインに必要な最小構成は何かと思っていました。アドバイスをお願いします。
2658 次
1 に答える
0
これで十分です (ポートの指定はオプションです。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 パッケージ org.codehaus.cargo:cargo-maven2-plugin:run (「war」をパッケージ化した mavenproject 上) よりも war を作成し、指定された URL から tomcat をダウンロードし、それを開始して war を展開します。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 docu (http://cargo.codehaus.org/Starting+and+stopping+a+container) からコピーしただけです。これにより、「統合テスト」の前にコンテナーが開始され、テストの後に停止されます。
于 2012-01-31T12:36:29.573 に答える