Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a simple way to use a different Spring version?

I want to use latest Spring 4.1.x snapshot in my Spring Boot project.

Is there a simple way to override the version of all Spring dependencies, or should I include all required Spring dependencies with it's desired version manually?

Reason is I want experiment with Spring 4.1 @JsonView annotation in REST services.

like image 429
Marcel Overdijk Avatar asked Jun 25 '14 06:06

Marcel Overdijk


2 Answers

If you're using Maven with spring-boot-starter-parent as the parent, you can override the spring.version property in your pom to change the version of Spring that you're using:

<properties>
    <spring.version>4.1.0.BUILD-SNAPSHOT</spring.version>
</properties>

If you're using Gradle, you can achieve the same effect by using a resolution strategy to override the version of everything with the org.springframework group id:

configurations.all {
    resolutionStrategy {
        eachDependency {
            if (it.requested.group == 'org.springframework') {
                it.useVersion '4.1.0.BUILD-SNAPSHOT'
            }
        }
    }
}
like image 196
Andy Wilkinson Avatar answered Sep 23 '22 17:09

Andy Wilkinson


I once again needed this and previous block doesn't work anymore, causing already dependencies to be failed.

Anyway this works:

configurations.all {
    resolutionStrategy {
        eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == "org.springframework") {
                details.useVersion "4.1.0.RC1"
            }
        }
    }
}
like image 35
Marcel Overdijk Avatar answered Sep 24 '22 17:09

Marcel Overdijk