防止 Spring Boot 中的依赖版本覆盖

问题描述 投票:0回答:2

假设用户手动覆盖了Spring管理的依赖版本,是否有插件或其他工具可以告诉他们“不要这样做”。

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.7.5</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.7.3</version> <!-- this line shouldn't exist -->
  </dependency>
  <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.10.0</version> <!-- this line shouldn't exist -->
  </dependency>
</dependencies>

我问这个问题是因为当团队更新他们的货币应用程序时,他们会手动更新 20 多个依赖项版本,如果可能的话,他们只需要更新 Spring Boot 版本即可接收其他依赖项的更新。

spring-boot maven
2个回答
0
投票

这就是代码审查的首要目的。 Sonarcube 中可能有一个选项可以提供帮助,但还没有听说过 Maven 插件。

当然,根据版本之间的变化,您的项目很可能在这种状态下甚至无法编译。 Jackson databind 版本顺便说一句应该在那里,除非由于某种原因整个依赖项应该在那里,因为它是由另一个依赖项隐式引入的(我的脑海中没有 Spring Boot 启动器的所有瞬态依赖项,我知道这令人震惊)。


0
投票

spring-boot-dependency-checker 将为你做这件事

© www.soinside.com 2019 - 2024. All rights reserved.