如何在maven中调用exec:java插件时传递systemProperties? [英] How to pass systemProperties when invoking exec:java plugin in maven?
问题描述
我想使用exec:java插件从命令行调用主类。我可以使用 -Dexec.args =arg0 arg1 arg2
从命令行传递参数,我不知道如何传递系统属性。我试过'-Dexec.systemProperties =key = value`但没有效果。
I want to use the exec:java plugin to invoke the main class from command line. I can pass arguments from the command line using -Dexec.args="arg0 arg1 arg2"
, I don't know how to pass system properties. I tried '-Dexec.systemProperties="key=value"` but with no effect.
pom.xml
看起来像这样:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>ibis.structure.Structure</mainClass>
</configuration>
</plugin>
推荐答案
无法设置< systemProperties>
参数在命令行上。
There is no way to set the <systemProperties>
parameter on the command line.
但是,由于 exec:java
未分叉,你可以通过maven的系统属性,它也会被 exec:java
选中。
However, since exec:java
is not forked, you can just pass a system property to maven and it will be picked up by exec:java
as well.
mvn -Dkey=value exec:java -Dexec.mainClass=com.yourcompany.yourclass \
-Dexec.args="arg1 arg2 arg3"
这篇关于如何在maven中调用exec:java插件时传递systemProperties?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!