我正在从junit 4迁移到junit5。在分析依赖关系时遇到了一个问题。 当我运行mvndependency:analyze时,发生错误:
[WARNING] Used undeclared dependencies found:
[WARNING] junit:junit:jar:4.13:test
[INFO] Add the following to your pom to correct the missing dependencies:
[INFO]
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
我的pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<ignoredDependencies>
<ignoredUsedUndeclaredDependencies>junit:junit:jar:4.13</ignoredUsedUndeclaredDependencies>
</ignoredDependencies>
</configuration>
</execution>
</executions>
</plugin>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
请帮助我们消除此错误
答案 0 :(得分:1)
使用的未声明依赖项是必需的,但尚未在项目中明确声明为依赖项。直接声明使用的依赖项而不依赖于传递性依赖项是一种很好的样式。这不是问题,这不是很好。
您应该调查,代码的哪些部分使用JUnit 4代码。为了简化搜索,您可以暂时将其排除:
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
由于您在示例中未显示任何版本,所以我无法确定传递依赖项的来源,因此也将排除项放在何处。