2

mavenを介してjettyを起動するときに、test/resourcesフォルダーにあるjndi.propertiesファイルをロードする方法を探しています。私はextraClasspathとscannTargetPatternsでそれをやろうとしましたが、何もうまくいきません。以下に、jetty を開始および停止する私の 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 ファイルを見つけられないという nullpointer が表示されます。

<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 に答える