DEV Community

Jan Cizmar Subscriber for Tolgee

Posted on

4 1

Overriding dependency version in Spring Boot

Do you know that feeling when you spend hours trying to do something without any luck and then you find out that the solution could not be easier? Well, that just happened to me. I was trying to upgrade the Hibernate version in our Spring boot app.

What doesn't work

I tried to exclude the dependency from spring boot and include the desired one the standard gradle way. With no luck...

    implementation ("org.springframework.boot:spring-boot-starter-data-jpa"){
        exclude group: 'org.hibernate.orm', module: 'hibernate-core'
        exclude group: "org.hibernate.orm", module: "hibernate-jpamodelgen"
    }
    implementation "org.hibernate:hibernate-core:$hibernateVersion"
Enter fullscreen mode Exit fullscreen mode

After hours of trying to diagnose why I always got the version included in Spring Boot, I found out that there is the Spring Boot dependency management plugin. That's the plugin which handles all the spring boot versions and enforces the versions defined by spring boot.

What works

Fortunately, there is a way to override the version. And it's super easy.

You just need to specify the version in your build.gradle.

ext['<dependency>.version'] = '6.0.9'
Enter fullscreen mode Exit fullscreen mode

or using properties.gradle:

spring-framework.version=6.0.9
Enter fullscreen mode Exit fullscreen mode

as stated here in the Spring docs.

And voilà! It works! You can find the list of the version properties you can override here.

Hope this helps future travelers who will struggle with the same.

Thanks for reading, and please consider using and staring Tolgee platform on GitHub ⭐️ - a tool healing your localization pain.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay