Mad*_*jha 4 maven-3 spring-boot
Spring Boot 文档建议您在实践中大多数情况下不需要覆盖 BOM 依赖项。
因为有一些规定可以覆盖依赖关系。场景 :: 在父 pom 中声明:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
在子 pom 中声明
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
用更高版本覆盖 spring-boot-starter-data-mongodb 是否正确/最佳实践让我们说 spring boot 2.1.4 是 2.2.1
我的看法是用降级版本覆盖理论上似乎没问题,但升级到更高版本可能会引发问题。
此外,尽管覆盖了父 pom 中的声明,被覆盖依赖项的依赖项仍然按照 BOM 声明。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
我认为这样做有风险,但有时又不得不这样做。您或团队必须权衡利弊。以下是一些可能导致依赖项版本提前于 BOM 的情况。
执行此操作之前需要考虑的事项:
| 归档时间: |
|
| 查看次数: |
1795 次 |
| 最近记录: |