English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Spring Boot automatically manages dependencies and configurations. Each Spring Boot version provides a list of dependencies it supports. The dependency list can be checked with Maven Used together Material listPart of (Spring Boot dependencies). Therefore, we do not need to specify the version of the dependencies in the configuration. Spring Boot manages them automatically. When we update the Spring Boot version, Spring Boot will automatically upgrade all dependencies in a consistent manner.
Provide centralized dependency information by specifying a Spring Boot version in one place. It will be helpful when switching from one version to another. It avoids mismatches between different versions of Spring Boot libraries. We just need to write a library name and specify the version. It is very useful in multi-module projects.
Maven project from spring-boot-starter-parent inherits the following features:
default Java compiler version UTF-8 source encoding it gets from spring-boot-dependency-pom inherits a Dependency Section .It manages the versions of common dependencies. For this dependency, it will ignore
When configuring the project, the following spring-boot-starter-parent will be automatically inherited.
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.2.BUILD-SNAPSHOT</version> <!-- lookup parent from repository --> <relativePath/> </parent>
For example, if you want to add another dependency with the same artifact as the one injected, inject the dependency again <properties>tag to override
We can also use <java.version>Use the tag to change the Java version.
<properties> <java.version>1.8</java.version> </properties>
We can also add pom.xml file Add Maven plugin.It will package the project into an executable jar in the file.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
If we do not want to use spring-boot starter-parent If we want to adopt the advantages of dependency management while still using dependencies, we can use
<dependencyManagement> <dependencies> <dependency><!-- dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.2.2.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
The above dependencies do not allow overrides. To achieve overrides, we need to import
For example, to upgrade another spring-data-releasetrain , add the following dependencies to the pom.xml file.
<dependencyManagement> <dependencies> !--Override Spring Data release train--> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain/artifactId> <version>Fowler-SR2</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.2.2.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>