spring-boot - maven:替换传递依赖版本
问题描述
这里有一个mvn dependency:tree
片段:
...
+- org.springframework.boot:spring-boot-starter-actuator:jar:2.1.12.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.1.12.RELEASE:compile
[INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:2.1.12.RELEASE:compile
[INFO] | \- io.micrometer:micrometer-core:jar:1.1.9:compile
...
如您所见,我的项目使用的是 1.1.9 版本的io.micrometer:micrometer-core
.
我想使用这个库的最新版本。
这个版本是由于:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.12.RELEASE</version>
</parent>
我无法更改此版本。
有没有办法只io.micrometer:micrometer-core:1.1.19
被另一个最近的覆盖?
解决方案
覆盖传递依赖的最佳方法是将版本放入<dependencyManagement>
.
只需添加一个条目
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>...</version>
</dependency>
到<dependencyManagement>
您的 POM 部分。这将覆盖传递依赖,但不会影响直接依赖。此外,如果这个 jar 将来可能不再是传递依赖项,它将被忽略。
推荐阅读
- java - 如何从xml读取值并将其存储在java中的哈希映射中
- laravel - Laravel 数字验证 gte:5 也允许 0
- javascript - 幻灯片不接受属性中指定的宽度
- java - 是否最好为 Mockito 中的每个“何时”调用进行“验证”调用?
- javascript - 如何使表单元素填充表格行并启用表格的编辑、删除和更新按钮
- javascript - 从 vanilla JS 中的两个对象数组创建一个新的对象数组
- jboss7.x - 尝试从 Codeready Studio 12.19.1 停止 JBoss EAP 7.3 时出错
- java - Intellij IDEA 在构建时删除未使用的导入语句
- r - 总结部分单词的R函数?
- windows - 尝试在命令提示符窗口中逐行显示一些 ASCII 艺术作品,但在显示第一行后窗口关闭。我该如何解决?