我正在寻找如何在通过maven启动jetty时加载我在test / resources文件夹中的jndi.properties文件。我试图用extraClasspath和scannTargetPatterns来做这件事,但没有任何作用。下面你会发现我的pom片段开始和停止码头。这些文件位于src / test / resources / jndi_folder / local_jndi.properties和src / test / resources / jndi_folder / remote_jndi.properties
scanTargetPatterns选择它们,因为我在控制台中获得了这个输出:
[INFO] Adding extra scan target from pattern: services/src/test/resources/jndi_folder /local_jndi.properties
[INFO] Adding extra scan target from pattern: services/src/test/resources/jndi_folder/remote_jndi.properties
但是当我运行集成测试时,我得到一个nullpointer,说我的代码找不到.properties文件。
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<webApp>
${basedir}/target/messages
</webApp>
<contextPath>
messages
</contextPath>
<stopKey>stop</stopKey>
<stopPort>8005</stopPort>
<daemon>true</daemon>
<scanTargetPatterns>
<scanTargetPattern>
<directory>
${basedir}/src/test/resources
</directory>
<includes>
<include>**/*.properties</include>
</includes>
</scanTargetPattern>
</scanTargetPatterns>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
如果有人能帮助我,那就太好了。
干杯
答案 0 :(得分:1)
尝试将以下内容添加到配置标记中:
<useTestClasspath>true</useTestClasspath>