因为我试图在我的maven项目中设置一个嵌入容器,我希望它在集成测试阶段运行。我有两个码头问题,我无法解决:Jetty守护进程和useTestClasspath,我做错了什么?
<daemon>true</daemon>
没有预期的效果。服务器运行,但它然后锁定构建过程(实际上它阻止单元测试)。 那么我应该放置那个配置?<useTestClasspath>true</useTestClasspath>
对我来说是一个谜。我不想使用src/main/webapp/WEB-INF/lib
来放置postgresql jar(由jetty为数据源(postegresql-driver)调用),因为它将被嵌入到应用程序中,我不希望它在战争中(客户端)。所以我想使用<useTestClasspath>true</useTestClasspath>
,但是当我把postgresql放在src/test/resources
中时,它没有找到/识别它。 那么,我该如何使用该属性?
下面是完整的插件配置:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.9</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war</goal>
</goals>
<configuration>
<useTestClasspath>true</useTestClasspath>
<daemon>true</daemon>
<contextPath>agepro-prototype</contextPath>
<webApp>
${project.build.directory}/agepro-prototype.war
</webApp>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>9091</port>
</connector>
</connectors>
<stopPort>9092</stopPort>
<stopKey>test</stopKey>
</configuration>
</plugin>
在此先感谢您的帮助,你能提供给我。我必须为我的语法道歉,因为我的英语很不好。
问候,
Depado
我唯一的问题是,PostgreSQL是在应用程序的服务器端使用,我想测试客户端。所以postgresql是在我的pom中声明的,但它在主要范围内而不在测试范围内。我正在尝试你在这里发送的代码。 它工作正常!非常感谢 !现在我试图运行码头容器,而不是阻塞生命周期的其余部分。 ' true '似乎不起作用。 –
Depado
http://docs.codehaus。org/display/MAVENUSER/Maven +和+ Integration + Testing - 我在你的pom中看到的一个区别是使用run-war目标,而不是上面文章中指定的运行目标 - 可以看出它为什么会产生差异,但可能值得一试? –
已经尝试过。我尝试过运行,运行战争,部署战争(但因为我的jetty版本没有工作),而且它仍然阻止我的生命周期。硒插件和它的属性''工作正常......我不知道该怎么做。 –
Depado