Spring Boot depends on

Spring Boot is easy to use by adding base dependencies in one of two ways

1. Inherit the spring-boot-starter-parent project

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> < version > 1.5.6. RELEASE < / version > < / parent >Copy the code

2. Import the spring-boot-dependencies dependencies project

<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> < artifactId > spring - the boot - dependencies < / artifactId > < version > 1.5.6. RELEASE < / version > < type > pom < type > <scope>import</scope> </dependency> </dependencyManagement>Copy the code

Spring Boot dependency points

1. Attribute override is only valid for inheritance

This only works if your Maven project inherits (directly or indirectly) from spring-boot-dependencies. If you have added spring-boot-dependencies in your own dependencyManagement section with import you have to redefine the artifact yourself instead of overriding the property.

The versions of components in the Spring Boot dependency package are bound to the current Spring Boot. If you want to change the versions of components in the dependency package, you only need to add the following attributes to override the versions. However, this method is only effective for inheritance and does not apply to import.

. < the properties > < slf4j version > 1.7.25 < slf4j. Version > < / properties >Copy the code

If you want to upgrade the version in an imported way to achieve the above effect, you can also do this by placing the component dependencies to be upgraded before Spring Boot.

<dependencyManagement> <dependencies> <! -- Override Spring Data release train provided by Spring Boot --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain</artifactId> <version>Fowler-SR2</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.6.RELEASE</version> <type> POm </type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>Copy the code

Each Spring Boot release is designed and tested against a specific set of third-party dependencies. Overriding versions may cause compatibility issues.

Note that changing dependent component versions of Spring Boot may cause incompatibility issues.

2. Resource file filtering

${} = ${}; ${} = ${}; At sign wrap, otherwise invalid. In addition, @… The @ placeholder fails to compile in the YAML file editor, so using inheritance is problematic and takes time to navigate.

Recommended reading

Dry goods: 2TB architect four-stage video tutorial

Interview: the most complete Java multithreaded interview questions and answers

Interview: the most comprehensive ali advanced Java interview questions in history

Interview: The most complete Spring interview questions in history

Tutorial: The most complete Spring Boot complete video tutorial

Books: 15 must-read books for advanced Java architects

Tools: Recommended an online creation flow chart, mind mapping software

Share Java dry goods, high concurrency programming, hot technology tutorials, microservices and distributed technology, architecture design, blockchain technology, artificial intelligence, big data, Java interview questions, and cutting-edge hot news.