【问题标题】:Running Spring Boot cmd-line sample gives `Could not find method run()`运行 Spring Boot 命令行示例给出`Could not find method run()`
【发布时间】:2015-11-27 03:02:34
【问题描述】:

我正在尝试使用 Spring Boot 创建一个简单的命令行实用程序。

我从 Spring Boot 示例 here 开始。

运行gradle build 给出:

在根项目“spring-boot-sample-simple”上找不到参数 [build_54mbijt3lmz0e8z5tqchytm9o$_run_closure2@65b43076] 的方法 run()。

gradle build file 缺少什么以使其正常运行?

【问题讨论】:

  • 请分享构建脚本的相关部分。

标签: java gradle spring-boot command-line-interface


【解决方案1】:

似乎是 build.gradle 文件中的拼写错误,或者由于插件版本更改而未正确更新。它有一个run 任务(在插件的第一个版本中可用),它还不存在,但应用于此示例的spring-boot-gradle-plugin 提供了一个bootRun 任务而不是它。你可以阅读它in the official reference

你可以重命名一个:

run {
  systemProperties = System.properties
}

bootRun {
  systemProperties = System.properties
}

然后使用gradle bootRun 来构建和运行这个应用程序,或者只使用gradle build 来构建它。

【讨论】:

    【解决方案2】:

    如果您打开项目 build.gradle 文件并像这样注释掉这些行:

    /*
    run {
      systemProperties = System.properties
    }
    */
    

    它会构建好的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 2021-05-04
      • 1970-01-01
      • 2017-10-08
      • 1970-01-01
      相关资源
      最近更新 更多