【问题标题】:Passing command Line Arguments for grails run-app through gradle task通过 gradle 任务为 grails run-app 传递命令行参数
【发布时间】:2016-06-22 19:16:42
【问题描述】:

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

我想读取配置文件中的参数以进行运行时操作。根据 yml 配置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'.

如果我在这里遗漏了什么或者是否有更好的方法,请告诉我。

【问题讨论】:

    标签: grails gradle grails-3.0


    【解决方案1】:

    所以我找出问题所在。

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

    bootRun {
        systemProperties = System.properties
    }
    

    希望对大家有所帮助。

    【讨论】:

    • 是否可以以类似的方式将 args 也传递给 Application.class?
    猜你喜欢
    • 1970-01-01
    • 2021-04-21
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    • 2014-10-17
    相关资源
    最近更新 更多