Java and Spring Level 1 This level · 79 of 105
Easy java spring

How does Spring Boot manage dependency versions automatically?

The 30 second answer

Spring Boot manages versions through its dependency bill of materials, which provides a tested set of library versions. In Maven, I get that through the Spring Boot parent or by importing the BOM. In Gradle, I use dependency management or a platform dependency. I can then omit versions for managed libraries such as Jackson or Hibernate. Starters group the dependencies I need; the BOM supplies their versions, not the starter itself.

Could you say this in an interview?

1. The BOM. In the Spring Boot repository, each managed library is declared in one Gradle file:

library("HikariCP", "7.0.2") {
    group("com.zaxxer") {
        modules = [
            "HikariCP"
        ]
    }
}

spring-boot-dependencies/build.gradle L614-L624. This file is published as a Maven BOM (org.springframework.boot:spring-boot-dependencies) with a <dependencyManagement> section.

2. Using it with Maven:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>4.0.9</version>
</parent>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webmvc</artifactId>
    <!-- no version -->
</dependency>

The parent also sets Java version, encoding, and plugin configuration. If you already have a parent, import spring-boot-dependencies with <scope>import</scope> instead.

3. Using it with Gradle:

plugins {
    id 'org.springframework.boot' version '4.0.9'
    id 'io.spring.dependency-management'
}

or implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES).

4. Overriding a version. With the Maven parent or the dependency-management plugin, override a property:

<properties>
    <hikaricp.version>x.y.z</hikaricp.version>
</properties>

Property names are listed in the reference appendix "Version properties". Only override with care: the BOM versions are tested together.

Why this matters:

  • No version conflicts between Spring Framework, Hibernate and Jackson that you must solve yourself.
  • Upgrading Spring Boot upgrades a consistent set of libraries.
  • Starters stay simple: they list artifacts, not versions.

Interview distinction: Maven <dependencyManagement> only sets versions; it does not add dependencies. The starter adds the dependency; the BOM decides its version.

Sources (3)
  1. Spring Boot reference: Dependency managementdocs.spring.io
  2. Spring Boot Maven plugin: Using the plugin (parent and BOM)docs.spring.io
  3. Spring Boot reference appendix: Version propertiesdocs.spring.io
Previous
Next