Spring Boot Dependency Management
Spring Boot manages dependencies and configuration automatically. Each release of Spring Boot provides a list of dependencies that it supports. The list of dependencies is available as a part of the Bills of Materials (spring-boot-dependencies) that can be used with Maven. So, we need not to specify the version of the dependencies in our configuration. Spring Boot manages itself. Spring Boot upgrades all dependencies automatically in a consistent way when we update the Spring Boot version.
Advantages of Dependency Management
Note: Spring Boot also allows overriding of dependencies version, if required.
Maven Dependency Management System
The Maven project inherits the following features from spring-boot-starter-parent:
Inheriting Starter Parent
The following spring-boot-starter-parent inherits automatically when we configure the project.
Note: In the above dependency, we have specified only the Spring Boot version. If we want to add additional starters, simply remove the <version> tag. Similarly, we can also override the individual dependency by overriding a property in our project.
For example, if we want to add another dependency with the same artifact that we have injected already, inject that dependency again inside the <properties> tag to override the previous one.
Changing the Java version
We can also change the Java version by using the <java.version> tag.
Adding Spring Boot Maven Plugin
We can also add Maven plugin in our pom.xml file. It wraps the project into an executable jar file.
Spring Boot without Parent POM
If we don't want to use spring-boot starter-parent dependency, but still want to take the advantage of the dependency management, we can use <scope> tag, as follows:
Note: It does not maintain the plugin management.
The above dependency does not allow overriding. To achieve the overriding, we need to add an entry inside the <dependencyManagement> tag of our project before the spring-boot-dependencies entry.
For example, to upgrade another spring-data-releasetrain, add the following dependency in the pom.xml file.