org.springframework.boot Configuration with name 'runtime' not found

Viewed 10989

When trying to run my program using gradle bootRun, the error shows that

Failed to apply plugin 'org.springframework.boot' Configuration with name 'runtime' not found

The following is my 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")
}
2 Answers

I assume you're using Gradle 7. In Gradle 7, the configurations compile, testCompile, runtime and testRuntime have been removed in favor of implementation, testImplementation, runtimeOnly and testRuntimeOnly. That's why Gradle issues

Failed to apply plugin 'org.springframework.boot' Configuration with name 'runtime' not found

To fix the issue, you should use the Gradle version that is supported by the Spring Boot Gradle Plugin version you're using (1.5.3, according to the snippet provided). The system requirements lists Gradle version 2 and 3 as requirement for Spring Boot 1.5.3. Everything thereafter is not supported.

Spring Boot 2.5.0 supports Gradle 6.8, 6.9, or 7.x

See here for a good reference on Gradle 7 configurations: https://docs.spring.io/spring-boot/docs/2.5.0/gradle-plugin/reference/htmlsingle/

This will get you off the ground:

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()
}
Related