Tôi cần thực hiện một số kiểm tra với maven và chuyển một tham số từ dòng lệnh.chuyển một tham số java từ maven
Mã java của tôi sẽ nhận tham số là: System.getenv ("my_parameter1");
và tôi xác định thông số trong tệp pom.xml làm ví dụ bên dưới: (và sau này, tôi sửa đổi tệp pom.xml để lấy thông số từ dòng chung mvn clean install -Dmy_parameter1 = value1)
nhưng không hoạt động; System.getenv ("my_parameter1") trả về null. Tôi nên xác định tham số trong tệp pom.xml như thế nào?
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>
Chỉ cần kiểm tra: Thuộc tính hệ thống của Maven là * không * tự động được chuyển đến các thử nghiệm. – SiKing