当我运行"mvn干净安装“时,我得到了这些错误,那么修复这个问题的正确方法是什么呢?我试图将junit的版本改为5.7.0,但它会导致更多的错误,有人能帮我吗?
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for org.junit.jupiter:junit-jupiter-api:5.5.2 paths to dependency are:
+-my-service:1.0.0-SNAPSHOT
+-org.junit.jupiter:junit-jupiter-api:5.5.2
and
+-my-service:1.0.0-SNAPSHOT
+-org.junit.jupiter:junit-jupiter-engine:5.5.2
+-org.junit.jupiter:junit-jupiter-api:5.5.2
and
+-my-service:1.0.0-SNAPSHOT
+-org.springframework.boot:spring-boot-starter-test:2.4.1
+-org.junit.jupiter:junit-jupiter:5.7.0
+-org.junit.jupiter:junit-jupiter-api:5.5.2 (managed) <-- org.junit.jupiter:junit-jupiter-api:5.7.0
and
+-my-service:1.0.0-SNAPSHOT
+-org.springframework.boot:spring-boot-starter-test:2.4.1
+-org.mockito:mockito-junit-jupiter:3.6.28
+-org.junit.jupiter:junit-jupiter-api:5.5.2 (managed) <-- org.junit.jupiter:junit-jupiter-api:5.4.2
and
+-my-service:1.0.0-SNAPSHOT
+-org.springframework.boot:spring-boot-starter-test:2.4.1
+-org.junit.jupiter:junit-jupiter:5.7.0
+-org.junit.jupiter:junit-jupiter-params:5.7.0
+-org.junit.jupiter:junit-jupiter-api:5.5.2 (managed) <-- org.junit.jupiter:junit-jupiter-api:5.7.0
, 发布于 2021-06-07 19:51:36
该规则似乎强制执行一组依赖项的公共上界:这可能用于实现二进制兼容性(例如:确保不使用与您使用的传递依赖关系不兼容的较低版本,因为它的版本会更大)。
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireUpperBoundDeps failed with message:
Failed while enforcing RequireUpperBoundDeps. The error(s) are [
Require upper bound dependencies error for org.junit.jupiter:junit-jupiter-api:5.5.2 paths to dependency are:
+-my-service:1.0.0-SNAPSHOT
+-org.junit.jupiter:junit-jupiter-api:5.5.2
and
+-my-service:1.0.0-SNAPSHOT
+-org.junit.jupiter:junit-jupiter-engine:5.5.2
+-org.junit.jupiter:junit-jupiter-api:5.5.2
and
+-my-service:1.0.0-SNAPSHOT
+-org.springframework.boot:spring-boot-starter-test:2.4.1
+-org.junit.jupiter:junit-jupiter:5.7.0
+-org.junit.jupiter:junit-jupiter-api:5.5.2 (managed) <-- org.junit.jupiter:junit-jupiter-api:5.7.0spring是在5.7.0版本导入junit,但您已经指定了junit 5.5.2。
尝试使用最高版本(例如: 5.7.0)。
发布于 2021-06-07 20:08:43
Maven使用最近定义规则确定工件版本。--也就是说,它在依赖树中使用与项目最接近的依赖项的版本。始终可以通过在项目的POM中显式声明版本来保证版本。请注意,如果两个依赖关系版本在依赖树中处于相同的深度,则第一个声明将获胜。
最浅薄的人获胜。
Your project dependencies
+-A
+-B
+-C
+-D-2.0
+-E
+-D-1.0 <- This version is used for artifact D as this is "nearest".解决方案:将pom.xml中的版本更新为输出中列出的最新版本,即您的示例中的5.7.0。
您可以打印依赖树mvn dependency:tree并查看实际冲突的位置。
https://stackoverflow.com/questions/67877658
复制相似问题