我有一个grails 3应用程序,当我通过gradle bootRun
任务运行时,我试图将命令行参数传递给我的应用程序。
我想在配置文件中读取运行时操作的参数。根据yml configration here的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:\docs\projects\jet\build.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'.
如果我在这里遗失了任何内容,或者有更好的方法,请告诉我。
答案 0 :(得分:2)
所以我发现问题是什么。
Grails 3.0使用bootRun
作为目标,而不是run
。更改添加以下代码修复了问题。
bootRun {
systemProperties = System.properties
}
希望这有助于每个人。