mavenでいくつかのテストを実行し、コマンドラインからパラメータを渡す必要があります。mavenからjavaパラメータを渡す
私のJavaコードは、パラメータを次のように取得する必要があります。 System.getenv( "my_parameter1");
と私は以下の例のようにpom.xmlファイルでパラメータを定義: (後者を、私はきれいな-Dmy_parameter1 = VALUE1をインストールする共通線MVNからパラメータを取得するためのpom.xmlを修正したい)
ただし、動作しません。 System.getenv( "my_parameter1")はnullを返します。 pom.xmlファイルでパラメータをどのように定義する必要がありますか? pom.xmlに環境変数にアクセスするための
のpom.xml
<project>
...
<profiles>
<profile>
<properties>
<my_parameter1>value1</my_parameter1>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>slowTest</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/*Test.java</include>
<include>**/*TestSlow.java</include>
</includes>
<properties>
<my_parameter1>value1</my_parameter1>
</properties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
ちょうどチェックされています:Mavenシステムのプロパティはテストに自動的に渡されません。 – SiKing