2

我使用 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>

allworks 文件,但是如果在应用程序部署过程中出现错误,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 构建失败。

谢谢你。

4

0 回答 0