2

Eclipse で Junit テスト ケースを実行している間、DB 構成用の VM 引数を で渡しています-Dが、同じ Junit テスト ケースを Maven で Sonar にアップロードしている間、VM 引数が設定されていないため機能しません。

MAVEN_OPTSon で引数を渡そうとしましたMVN.shが、うまくいきません。

4

1 に答える 1

0

システム プロパティを使用してコマンド ラインで 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

于 2012-09-26T13:46:08.950 に答える