Eclipse で Junit テスト ケースを実行している間、DB 構成用の VM 引数を で渡しています-D
が、同じ Junit テスト ケースを Maven で Sonar にアップロードしている間、VM 引数が設定されていないため機能しません。
MAVEN_OPTS
on で引数を渡そうとしましたMVN.sh
が、うまくいきません。
システム プロパティを使用してコマンド ラインで DB 構成を設定する代わりに、プロファイルを使用して設定することを検討してください。
次のようなものを pom.xml に追加します。
<profiles>
<profile>
<id>sonar</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.3</version>
<configuration>
<systemPropertyVariables>
<db.user>foo</db.user>
<db.password>bar</db.password>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
ドキュメンテーション:
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html