【发布时间】:2016-05-11 20:11:00
【问题描述】:
我仍然遇到问题如何在 Maven 中配置码头插件,以便能够使用 maven-surefire-plugin 启动它运行测试,然后停止码头服务器。到目前为止,它只是运行码头并等待并且它不会继续。另一个问题是插件何时应该是 jetty-maven-plugin 或 maven-jetty-plugin。我没有他们之间的区别。无论如何,这里是我的 pom.xml 的摘录。
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<!--version>9.2.11.v20150529</version-->
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/hellojavaworld</contextPath>
</webApp>
<war>c:\apache-tomcat-7.0.64\webapps\hellojavaworld.war</war>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<!--configuration>
<daemon>true</daemon>
</configuration-->
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<excludes>
<exclude>*.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>*.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
在控制台中只是:
[INFO] 已启动 Jetty 服务器
[INFO] 每隔 10 秒启动一次扫描仪。
我希望它启动码头、运行测试(需要 servlet 容器)、停止码头并编写 BUILD SUCCESSFUL。
有人有什么建议吗? 提前致谢。
【问题讨论】: