我只是想maven-enforcer-plugin
用一个小的 pom 来获取(在我进入我的项目 pom 之前,它有 100 多个依赖项。)
在我添加了执行器插件之后,我看到了Dependency convergence error
. pom.xml文件在下面(抱歉它不整洁)
。
如何在不禁用强制插件的情况下修复错误。
基本上我想了解如何使用规则背后的概念。dependencyConvergence
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>enforcer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<!--
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.2.13.RELEASE</version>
</dependency>
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.10.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.5</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.4.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>dependency-convergence</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence/>
</rules>
</configuration>
</execution>
</executions>
<configuration>
<rules>
<dependencyConvergence />
</rules>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是否意味着,我必须在此版本的pom.xml中显式声明dependencyManagement 中的每个非收敛依赖项(将依赖项添加到dependencyManagement)。
问题spring-context
仍然存在,因为我已将其添加为直接依赖项,然后在具有不同版本的依赖项管理中。
基本上 - 能够修复错误,但还不能清楚地掌握规则。
修复一个 - pom.xml - 将依赖管理中的版本更新为明确使用的版本。所以现在不需要在依赖项中明确给出版本。但这需要我能够访问父 pom 的dependencyManagment。如果我的说法是正确的,那么情况可能并非每次都如此。
修复两个pom.xml - 从 spring-security-web 中排除 spring-context 并且它有效。但是,如果要进行十几个排除,那将是一件痛苦的事情。
如果这是采用收敛规则的方法?在具有 100 多个依赖项和 100 多个传递依赖项的企业项目中,物料清单 (BOM) 将非常庞大并且需要时间来构建。嗯。(我同意,对使用的版本和使用 <xyz.version> 之类的属性会有更多的控制,升级可以轻松完成)。
如果有人能列出涉及收敛的规则,我将不胜感激。