小编Mad*_*jha的帖子

使用更高版本覆盖 Spring Boot BOM 策划的依赖项

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)

maven-3 spring-boot

4
推荐指数
1
解决办法
1795
查看次数

标签 统计

maven-3 ×1

spring-boot ×1