Skip to content

How to resolve Spring Boot plugin requires Gradle 5 or Gradle 6 Exception when building springboot applications with gradle

Problem

When building Spring Boot applications with Gradle, you might encounter the following error:

Terminal window
Build file '/Users/bswen/private/bw/bswen-github/bswen-project/spring-boot-23/build.gradle' line: 2
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.3.2.RELEASE']
> Failed to apply plugin [id 'org.springframework.boot']
> Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 5.2.1

Environments

The environments are as follows:

  • Java version: JDK 1.8
  • Spring Boot version: 2.3.2.RELEASE

The build.gradle

The build.gradle file of this Spring Boot application is as follows:

build.gradle
plugins {
id 'org.springframework.boot' version '2.3.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group 'com.bswen'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}

How to resolve the problem

This error occurs due to an incorrect Gradle version specified in the ./gradle/wrapper/gradle-wrapper.properties file. To resolve it, follow these steps:

  1. Open the ./gradle/wrapper/gradle-wrapper.properties file.
  2. Locate the line:
    distributionUrl=https\://services.gradle.org/distributions/gradle-5.0.1-bin.zip
  3. Change the version 5.0.1 to 5.6.1 or a higher version of Gradle.

After making this change, the gradle-wrapper.properties file should look like this:

gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

The code base for this example is available on GitHub. You can download it by visiting this web URL.

Summary

In this post, we discussed how to resolve the “Spring Boot plugin requires Gradle 5 or Gradle 6” exception when building Spring Boot applications with Gradle. The primary solution involves updating the Gradle version in the gradle-wrapper.properties file to a compatible version. Ensuring that your build tools are correctly configured is essential for avoiding such errors and maintaining a smooth development workflow.

Final Words + More Resources

My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!