Spring启动文档建议大多数情况下,您实际上不需要覆盖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>
在子pom中声明
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
重写spring-boot-starter-data-mongodb是否正确/最佳实践 具有更高版本的设备,例如说2.2.1用于春季靴2.1.4
我的观点是,降级后的版本在理论上是可以的,但是升级到更高版本可能会引起问题。
尽管重写了父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>
答案 0 :(得分:2)
我认为这样做有风险,但有时必须这样做。您或团队必须权衡利弊。在某些情况下,可能会导致在BOM表之前提前依赖项的版本。
在执行此操作之前要考虑的事项: