Java 当我使用junit 5时,发现使用了未声明的依赖项junit 4.13
我正在从JUnit4迁移到JUnit5。我在分析依赖项时遇到了一个问题。 运行mvn dependency:analyze时,出现错误:Java 当我使用junit 5时,发现使用了未声明的依赖项junit 4.13,java,maven,testing,junit,Java,Maven,Testing,Junit,我正在从JUnit4迁移到JUnit5。我在分析依赖项时遇到了一个问题。 运行mvn dependency: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] <dependenc
[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>
[警告]发现使用的未声明依赖项:
[警告]junit:junit:jar:4.13:test
[信息]将以下内容添加到pom以更正缺少的依赖项:
[信息]
朱尼特
朱尼特
4.13
测试
我的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>
org.apache.maven.plugins
maven依赖插件
分析
仅分析
junit:junit:jar:4.13
org.junit.platform
junit平台发射器
测试
org.junit.vintage
朱尼特老式发动机
测试
请帮助我们消除此错误。使用的未声明依赖项是必需的,但在项目中未明确声明为依赖项。直接声明所使用的依赖项而不依赖可传递依赖项是一种很好的方式。这不是问题,只是不好 您应该调查代码的哪些部分使用JUnit4代码。为了简化搜索,您可以暂时将其排除在外:
由于您在示例中没有显示任何版本,我无法判断可传递依赖项来自何处,因此将排除放在何处。使用的未声明依赖项是必需的,但在项目中未明确声明为依赖项。直接声明所使用的依赖项而不依赖可传递依赖项是一种很好的方式。这不是问题,只是不好 您应该调查代码的哪些部分使用JUnit4代码。为了简化搜索,您可以暂时将其排除在外:
由于您在示例中没有显示任何版本,我无法判断可传递依赖项来自何处,因此,将排除放在何处。此依赖关系用于org.junit.vintage:junit-vintage引擎:jar:5.6.2:test我使用命令mvn-dependency:tree,得到了以下依赖关系树\-org.junit.vintage:junit-vintage引擎:jar:5.6.2:test \-junit:junit:jar:4.13:test junit-vintage引擎的目的是支持较旧的JUnit 3/4测试。-如果你没有,那就扔掉老式引擎如果有,请按照错误消息中的描述声明对JUnit 4.13的依赖关系。我添加了JUnit 4.13依赖关系-错误不会再现。我想我应该添加一个复古依赖项并删除JUnit4.13。感谢您的回答。这个依赖关系用于org.junit.vintage:junit-vintage引擎:jar:5.6.2:test我使用命令mvn-dependency:tree,得到了以下依赖关系树\-org.junit.vintage:junit-vintage引擎:jar:5.6.2:test \-junit:junit:jar:4.13:test junit引擎的目的是支持较旧的junit3/4测试-如果你没有,那就扔掉老式引擎如果有,请按照错误消息中的描述声明对JUnit 4.13的依赖关系。我添加了JUnit 4.13依赖关系-错误不会再现。我想我应该添加一个复古依赖项并删除JUnit4.13。谢谢你的回答。