在 Java 中检索命令行 -D 选项
Retrieving command line -D options in Java
我有 clean integration-test -DclassId=app
作为 Jenkins Maven Job 的 maven 目标。
如何使用 System.getenv();
在 Java 中检索它?当我这样做时,我只看到空值。
对于命令行选项,您必须使用 System.getProperty()
instead of System.getenv()
:
String id = System.getProperty("classId");
查找更多详细信息here。
我有 clean integration-test -DclassId=app
作为 Jenkins Maven Job 的 maven 目标。
如何使用 System.getenv();
在 Java 中检索它?当我这样做时,我只看到空值。
对于命令行选项,您必须使用 System.getProperty()
instead of System.getenv()
:
String id = System.getProperty("classId");
查找更多详细信息here。