2

我正在寻找如何在通过 maven 启动码头时加载我的 jndi.properties 文件,这些文件位于 test/resources 文件夹中。我试过用 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

但是当我运行集成测试时,我得到一个空指针,说我的代码找不到 .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>

如果有人可以帮助我,那就太好了。

干杯

4

1 回答 1

1

尝试将以下内容添加到您的配置标签中:

<useTestClasspath>true</useTestClasspath>
于 2012-09-04T10:02:08.423 回答