首页 > 解决方案 > gradle:应用程序运行参数无法传递系统属性

问题描述

摇篮 5.4.1

apply plugin: application

run {
   main = "mypackage.Foo"
}

跑:

gradlew run --args="-Dfoo=bar -Dhello=world"

在运行应用程序时尝试使用 --args 传递系统属性。但他们没有设置。

标签: gradle

解决方案


gradlew -Dfoo=bar -Dhello=world run --args="arg1"

--args是传递给主要方法的内容。


推荐阅读