<project>
<parent>
<groupId>parent-pom</groupId>
<artifactId>parent-with-spring-dependencies</artifactId>
<version>1.0.0</version>
<relativePath/>
</parent>
<modules>
<module>xxx</module>
<module>yyy</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.xyz.abc</groupId>
<artifactId>spring-dependencies</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
</build>
</project>
spring-beans 在父 pom 中作为依赖管理存在,版本为 5.2.0.RELEASE,并且 spring-dependency pom 中有 dependencyManagement,其中 spring-beans 版本为 5.3.27。
在模块 xxx spring-beans 依赖项中存在没有版本的情况,并且它选择了parent-pom中存在的版本,而不是从dependencyManagement中存在的spring依赖项中选择它,我想要版本5.3.27。在不删除parent-pom的情况下我该怎么做才能实现这一目标。
如果父级中的版本是通过属性定义的,则只需覆盖该属性即可。
如果没有,请在 POM 中添加一个
dependencyManagement
条目来覆盖该版本。不是通过导入另一个 BOM,而是直接指定它。