自动配置原理

自动配置原理

Spring Boot 自动配置原理解析

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<!-- 跟踪父工程 -->
<!-- pom.xml -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<!-- spring-boot-starter-parent-2.3.2.RELEASE.pom -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.3.2.RELEASE</version>
</parent>

<!-- spring-boot-dependencies-2.3.2.RELEASE.pom -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>

最终在 spring-boot-dependencies 下发现了所有依赖以及其对应的版本号:

1
2
3
4
5
<properties>
    <activemq.version>5.15.13</activemq.version>
    <antlr2.version>2.7.7</antlr2.version>
 	......
</properties>

因此在Spring Boot的项目中,核心依赖在父工程中已经配好,我们只需要调用即可.

Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计