【发布时间】:2016-08-03 02:57:53
【问题描述】:
这是我的 pom.xml 文件:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<profiles>
<profile>
<id>my_proj</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>com.test.Main</argument>
</arguments>
<systemProperties>
<systemProperty>
<key>someKey</key>
<value>someValue</value>
</systemProperty>
</systemProperties>
<environmentVariables>
<someKey>
someValue
</someKey>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
在 Main.java 中
public static void main(String[] args) {
System.out.println("hello world" + System.getenv("someKey") + " " + System.getProperty("someKey"));
}
我运行时的输出
mvn install -Pmy_proj
是
hello worldsomeValue null
我似乎无法获得 systemProperty 值。我做错了什么?
【问题讨论】:
标签: java maven maven-3 pom.xml exec-maven-plugin