【问题标题】:spring-boot gradle plugin can't be found找不到spring-boot gradle插件
【发布时间】:2014-12-22 01:20:13
【问题描述】:

我有一个单独的 gradle 脚本,它只是添加了 spring-boot 插件。它看起来像这样:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url 'http://repo.spring.io/libs-release' }
    }
    dependencies {
        classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.8.RELEASE'
    }
}

apply plugin: 'spring-boot'

然后,在另一个项目中,它是这样引用的:

apply from: '../../food-orders-online-main/spring-boot.gradle'

当我运行构建任务时,出现以下错误:

A problem occurred evaluating script.
> Failed to apply plugin [id 'spring-boot']
> Plugin with id 'spring-boot' not found.

有人知道我做错了什么吗?

【问题讨论】:

  • 我收到了The plugin id 'spring-boot' is deprecated. Please use 'org.springframework.boot' instead.

标签: gradle spring-boot


【解决方案1】:

脚本插件不支持通过插件 ID 应用插件。您必须使用插件的完全限定类名。

apply plugin: org.springframework.boot.gradle.plugin.SpringBootPlugin

更多信息请参见this thread

更新:更新插件类名。

【讨论】:

  • Spring Boot 1.4.0 版本有什么变化吗?插件类名还是一样吗?
  • 这也解决了我的Spring Boot plugin requires Gradle * or later. The current version is Gradle *错误问题
【解决方案2】:

可能是,您的类路径中没有带有 main(String[] main) 的 @SpringBootApplication 吗??

【讨论】:

    【解决方案3】:

    从 SpringBoot 1.4.0.RELEASE 开始插件包略有改动。

    apply plugin: org.springframework.boot.gradle.plugin.SpringBootPlugin
    

    【讨论】:

      【解决方案4】:

      这些是我在 spring boot 2.0.1 上使用的插件

      apply plugin: 'java'
      apply plugin: 'org.springframework.boot'
      apply plugin: 'io.spring.dependency-management'
      

      我完整的原版 gradle 文件在这里(Spring boot 2.0.5)

      buildscript {
          ext {
              springBootVersion = '2.0.5.RELEASE'
          }
          repositories {
              mavenCentral()
          }
          dependencies {
              classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
          }
      }
      
      apply plugin: 'java'
      apply plugin: 'org.springframework.boot'
      apply plugin: 'io.spring.dependency-management'
      
      group = 'com.example'
      version = '0.0.1-SNAPSHOT'
      sourceCompatibility = 1.8
      
      repositories {
          mavenCentral()
      }
      
      
      dependencies {
          compile('org.springframework.boot:spring-boot-starter')
          testCompile('org.springframework.boot:spring-boot-starter-test')
      }
      

      还有一个更好的选择,去spring starter(spring boot 模板生成工具)start.spring.io 并从那里生成一个模板项目,然后从那里一步步构建。

      【讨论】:

      • 这也适用于 Gradle 4 和 Spring Cloud Finchley SR1。截至 2018 年 8 月,Spring Cloud Finchley SR1“快速入门”说明似乎适用于旧版本的 Gradle,因为如 Spring Cloud 网站上所述,它不适用于 Gradle 4。Spring Cloud 位于 Spring Boot 之上2.我只用这个答案让它工作。 (注意,此答案中未显示,但您还需要另一个答案中显示的 buildscript 部分。)
      【解决方案5】:

      此代码适用于我

       plugins{
      
        id 'org.springframework.boot' version '2.0.3.RELEASE'
      
       }
      

      【讨论】:

        【解决方案6】:
        1. 添加:

          buildscript {
              repositories {
                  maven {
                      url "https://plugins.gradle.org/m2/"
                  }
              }
              dependencies {
                  classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.4.RELEASE"
              }}
          
        2. 变化:

          apply plugin: 'spring-boot'
          

          到:

          apply plugin: "org.springframework.boot"
          

        【讨论】:

          【解决方案7】:

          检查您的语法以及括号关闭的位置} 我遇到了同样的问题,结果我的存储库{最后没有包含}

          【讨论】:

            【解决方案8】:

            截至 2020 年 7 月 1 日,这就是我能够配置它的方式,并且它有效!希望这可以帮助任何面临这个问题的人。 注意:注意版本

            buildscript {
                    repositories {
                        mavenCentral()
                    }
                    dependencies {
                        classpath('org.springframework.boot:spring-boot-gradle-plugin:2.2.8.RELEASE')
                    }
                }
                
                plugins {
                    id 'org.springframework.boot' version '2.2.8.RELEASE'
                    id 'java'
                }
                
                group 'org.capfer'
                version '1.0-SNAPSHOT'
                
                sourceCompatibility = 1.8
                
                repositories {
                    mavenCentral()
                }
                
                dependencies {
                    testCompile group: 'junit', name: 'junit', version: '4.12'
                    compile('org.springframework.boot:spring-boot-starter-web:2.2.8.RELEASE')
                }
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 2019-01-17
              • 2022-01-16
              • 1970-01-01
              • 2020-05-25
              • 2018-01-29
              • 2021-03-11
              • 1970-01-01
              相关资源
              最近更新 更多