- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Maven 3 中运行嵌入式 Tomcat 9 以进行集成测试。我被带到 cargo-maven2-plugin
通过其他 SO 答案。
因此,尝试按照此处找到的说明进行操作:
https://codehaus-cargo.github.io/cargo/Static+deployment+of+WAR.html
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>embedded</type>
</container>
<deployables>
<deployable>
<type>war</type>
<properties>
<file>path/to/myapp.war</file>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
mvn org.codehaus.cargo:cargo-maven2-plugin:run
执行
[INFO] [en2.ContainerRunMojo] Resolved container artifact org.codehaus.cargo:cargo-core-container-tomcat:jar:1.7.6 for container tomcat9x [WARNING] The defined deployable has the same groupId and artifactId as your project's main artifact but the type is different. You've defined a [war] type wher eas the project's packaging is [pom]. This is possibly an error and as a consequence the plugin will try to find this deployable in the project's dependencies.
最佳答案
在尝试了许多排列之后,这终于对我有用了:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.9</version>
<configuration>
<container>
<systemProperties>
<myvar1>${myEnvVar}</myvar1>
<myvar2>... stuff ...</myvar2>
</systemProperties>
<containerId>tomcat9x</containerId>
<zipUrlInstaller>
<url>https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/9.0.29/tomcat-9.0.29.zip</url>
</zipUrlInstaller>
</container>
<deployables>
<deployable>
<groupId>org.codehaus.cargo</groupId>
<artifactId>simple-war</artifactId>
<type>war</type>
<location>path/to/myapp.war</location>
<properties>
<context>myapp</context>
</properties>
</deployable>
</deployables>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
failsafe
插件在
start
之间自动运行集成测试和
stop
:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
关于maven - 如何在 Maven 3 中运行嵌入式 Tomcat 9 以进行集成测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59924534/
我是一名优秀的程序员,十分优秀!