【问题标题】:org.springframework.boot Configuration with name 'runtime' not foundorg.springframework.boot 未找到名为“runtime”的配置
【发布时间】:2021-07-31 15:23:57
【问题描述】:

当尝试使用 gradle bootRun 运行我的程序时,错误显示

未能应用插件“org.springframework.boot” 找不到名称为“runtime”的配置

以下是我的build.gradle

 buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE")
    }
}

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'

jar {
    baseName = 'blockchain-demo'
    version = '0.0.1'
}

war {
    baseName = 'blockchain-demo'
    version = '0.0.1'
}

application {
    mainClass = 'web.Application'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-devtools")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("junit:junit")
}

【问题讨论】:

    标签: java spring spring-boot gradle


    【解决方案1】:

    我假设您使用的是 Gradle 7。在 Gradle 7 中,配置 compiletestCompileruntimetestRuntime 已被删除,取而代之的是 implementationtestImplementationruntimeOnlytestRuntimeOnly。这就是 Gradle 出现问题的原因

    未能应用插件 'org.springframework.boot' 配置名称为 'runtime' 未找到

    要解决此问题,您应该使用您正在使用的 Spring Boot Gradle 插件版本支持的 Gradle 版本(1.5.3,根据提供的 sn-p)。 system requirements 将 Gradle 版本 2 和 3 列为 Spring Boot 1.5.3 的要求。此后的所有内容均不受支持。

    【讨论】:

      【解决方案2】:

      Spring Boot 2.5.0 支持 Gradle 6.8、6.9 或 7.x

      请参阅此处以获取有关 Gradle 7 配置的良好参考:https://docs.spring.io/spring-boot/docs/2.5.0/gradle-plugin/reference/htmlsingle/

      这会让你离开地面:

      plugins {
          id 'org.springframework.boot' version '2.5.0'
      }
      
      apply plugin: 'java'
      apply plugin: 'io.spring.dependency-management'
      
      dependencies {
          implementation('org.springframework.boot:spring-boot-starter-web')
          implementation('org.springframework.boot:spring-boot-starter-data-jpa')
      }
      
      repositories {
          mavenCentral()
      }
      

      【讨论】:

        猜你喜欢
        • 2019-08-04
        • 1970-01-01
        • 2019-01-13
        • 1970-01-01
        • 2013-06-15
        • 1970-01-01
        • 2017-08-21
        • 2018-02-08
        • 1970-01-01
        相关资源
        最近更新 更多