Home » Java » Enterprise Java » Override Spring Framework version in Spring Boot application built with Gradle

About Rafal Borowiec

Rafal Borowiec
Software developer, Team Leader, Agile practitioner, occasional blogger, lecturer. Open Source enthusiast, quality oriented and open-minded.

Override Spring Framework version in Spring Boot application built with Gradle

If you want to use or just check the newest version of Spring with Spring Boot but the current Spring Boot version depends on an older Spring version you need to adjust your Gradle build configuration slightly.

For example, as of time of writing this blog post, Spring 4.2.1 and Spring Boot 1.2.5 were current versions. Spring Boot 1.2.5 depends on Spring 4.1.7. So what to do to in order to use Spring 4.2.1 with Spring Boot 1.2.5? Have a look at two ways of achieving this: with and without Spring IO Platform.

Spring IO Platform

The idea of Spring IO Platform is to provide versions of libraries that are known to work together through Maven’s dependency management. The main reason you should consider Spring IO Platform for your project is that you don’t need to care about dependency versions of Spring projects along with their dependencies.

The Platform is also supported by Gradle via dependency management plugin – a plugin that provides Maven-like dependency management functionality. To use it you can simply import the Platform’s BOM into your application’s build.gradle file:

dependencyManagement {
    imports {
        mavenBom 'io.spring.platform:platform-bom:1.1.3.RELEASE'

If you happen to generate projects by Spring Initializr you will notice that Gradle’s dependency management plugin is already included. The remaining thing is to add the dependency management configuration, import the BOM as shown above and add dependencies without versions – as versions are provided by BOM.

Overriding dependency versions

Overriding version of a dependency is as easy as changing the value of the dependency version property that can be found in BOM and its ancestors here and here.

The properties can be changed in gradle.properties file:

spring.version = '4.2.1.RELEASE'

or in build.gradle file:

ext['spring.version'] = '4.2.1.RELEASE'

The above property defines a version of Spring framework. Overriding it lets you adjust Spring version in the Spring Boot application.

Assuming that you have Gradle 2.6 installed, execute dependencyInsight task:

gradlew dependencyInsight --dependency org.springframework

As you can see below, Spring 4.1.7 required by Spring Boot 1.2.5 was resolved to Spring 4.2.1:


org.springframework:spring-webmvc:4.1.7.RELEASE -> 4.2.1.RELEASE
\--- org.springframework.boot:spring-boot-starter-web:1.2.5.RELEASE
     \--- compile                 

org.springframework:spring-webmvc:4.1.7.RELEASE -> 4.2.1.RELEASE
\--- org.springframework.boot:spring-boot-starter-web:1.2.5.RELEASE
     \--- compile                 


Override Spring Version without Spring IO Platform

In case you are not familiar with the Platform or you are reluctant to use it, you may choose a simple workaround and replace the version of Spring framework with the following configuration:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'org.springframework') {
            details.useVersion "4.2.1.RELEASE"
(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments