通过Gradle任务传递了Grails Run-App的命令行参数



我有一个Grails 3应用程序,当我通过Gradle bootRun任务运行时,我试图将命令行参数传递给我的应用程序。

我想阅读配置文件中的参数以进行运行时操作。根据YML元素的Grails文档,我尝试将以下内容添加到我的build.gradle文件

run {
    systemProperties = System.properties
}

当我添加该配置并运行任务时,我会收到以下错误:

3:11:20 PM: Executing external task 'bootRun -Dcolor=red -Dfruit=apple'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:docsprojectsjetbuild.gradle' line: 85
* What went wrong:
A problem occurred evaluating root project 'jet'.
> Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8@4446881a] on root project 'jet'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.892 secs
Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8@4446881a] on root project 'jet'.
3:11:32 PM: External task execution finished 'bootRun -Dcolor=red -Dfruit=apple'.

请告诉我,如果我在这里缺少任何东西,或者是否有更好的方法。

,所以我知道问题是什么。

Grails 3.0使用bootRun作为目标而不是run。更改添加以下代码解决了问题。

bootRun {
    systemProperties = System.properties
}

希望这对每个人都有帮助。

最新更新