You need to enable JavaScript to run this app. 执行gradle bootRun报错org.springframework.boot的runtime配置未找到如何解决
优惠活动
大模型
产品
解决方案
定价
更多

执行gradle bootRun报错org.springframework.boot的runtime配置未找到如何解决

报错原因

你遇到的Configuration with name 'runtime' not found报错是版本不兼容导致的:你使用的spring-boot-gradle-plugin:1.5.3.RELEASE是2017年发布的旧版本,仅适配Gradle 2.9 ~ 4.x版本;如果你本地的Gradle版本在5.0及以上,旧版Spring Boot插件仍然会调用早已被Gradle官方移除的runtime依赖配置,就会触发该错误。

解决方案

这里提供两种可直接落地的修复方式,按需选择即可:

方案1:降级Gradle版本(无需修改项目依赖配置)

  • 下载并安装Gradle 4.x版本,替换本地当前使用的高版本Gradle
  • 重新执行gradle bootRun命令即可正常启动

方案2:升级Spring Boot版本(适配高版本Gradle)

如果要继续使用高版本Gradle,将Spring Boot插件及相关依赖升级到2.0及以上版本即可,修改后的build.gradle核心配置参考如下:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        // 升级到2.7.x稳定版,适配Gradle 6.x及以上版本
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.7.12")
    }
}

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
// Spring Boot 2.x+需要额外引入io.spring.dependency-management插件
apply plugin: 'io.spring.dependency-management'
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配置也已废弃,替换为implementation
    implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
    implementation("org.springframework.boot:spring-boot-devtools")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("junit:junit")
}

修改后重新执行gradle bootRun即可。

内容的提问来源于stack exchange,提问作者Aric

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.21 06:24:04