[英]JUnit 5 migration - how to solve java.lang.ClassNotFoundException: org.junit.jupiter.api.extension.ReflectiveInvocationContext
[英]why auto dependency is error version?(java.lang.ClassNotFoundException: org.junit.jupiter.api.MethodOrdererContext)
<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.4.0</version> <scope>test</scope> </dependency>
junit-jupiter-engine-5.4.0.pom 依賴項是
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.4.0:test
[INFO] | +- org.apiguardian:apiguardian-api:jar:1.0.0:test
[INFO] | +- org.junit.platform:junit-platform-engine:jar:1.3.2:test
[INFO] | | +- org.junit.platform:junit-platform-commons:jar:1.3.2:test
[INFO] | | \- org.opentest4j:opentest4j:jar:1.1.1:test
[INFO] | \- org.junit.jupiter:junit-jupiter-api:jar:5.3.2:test
但我運行mvn dependency:tree
,結果是這樣的:
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.4.0:test [INFO] | +- org.apiguardian:apiguardian-api:jar:1.0.0:test [INFO] | +- org.junit.platform:junit-platform-engine:jar:1.3.2:test [INFO] | | +- org.junit.platform:junit-platform-commons:jar:1.3.2:test [INFO] | | \\- org.opentest4j:opentest4j:jar:1.1.1:test [INFO] | \\- org.junit.jupiter:junit-jupiter-api:jar:5.3.2:test
構建工具: maven3.5.4
這是Gradle 5 JUnit BOM 和 Spring Boot Incorrect Versions 的副本。
解決方案是將以下內容添加到您的 Maven POM 中。
<properties>
<junit-jupiter.version>5.4.0</junit-jupiter.version>
</properties>
在將 Spring Boot 依賴項更新到最新版本並將 Juiper 引擎版本更新到 5.6.1 解決了我的問題后,我遇到了類似的問題。
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.1</version>
<scope>test</scope>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.