我使用maven tomcat插件启动嵌入式Tomcat并对其运行集成测试。
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>18000</port>
<fork>true</fork>
<webapps>
<webapp>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
</webapps>
</configuration>
<executions>
<execution>
<id>tomcat-start</id>
<goals>
<goal>run-war-only</goal>
</goals>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
所有工作文件,但如果在应用程序部署期间出现错误,Maven仍会报告成功构建,这会让人感到困惑。
SEVERE: Context [/my-web-app] startup failed due to previous errors
15-May-2014 18:08:03 org.apache.catalina.core.ApplicationContext log
然后
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:00.389s
[INFO] Finished at: Thu May 15 18:08:04 CEST 2014
[INFO] Final Memory: 56M/247M
[INFO] ------------------------------------------------------------------------
如果嵌入式Tomcat部署失败,我希望Maven构建失败。
谢谢。