gpt4 book ai didi

spring-boot - ClassNotFoundException : org. junit.platform.launcher.TestExecutionListener 运行 JUnit5 时

转载 作者:行者123 更新时间:2023-12-03 03:18:43 25 4
gpt4 key购买 nike

在我的 Intelly Idea 的基于 Gradle 的项目(Java Spring Boot 版本“2.0.3.RELEASE”)中,当我尝试调试单元测试时出现此错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/platform/launcher/TestExecutionListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:45)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.TestExecutionListener
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more

Gradle 版本是 4.8

Gradle 依赖项是:

testCompile("junit:junit:4.12")
testCompile(
'org.junit.jupiter:junit-jupiter-api:5.1.0'
)
testRuntime(
'org.junit.jupiter:junit-jupiter-engine:5.1.0',
'org.junit.vintage:junit-vintage-engine:5.1.0',
'org.junit.platform:junit-platform-launcher:1.1.0',
'org.junit.platform:junit-platform-runner:1.1.0'
)


我缺少什么设置,我该如何解决这个问题?

最佳答案

尝试运行

gradle test 

在命令行上。这应该显示更详细的输出以帮助诊断问题。

关于spring-boot - ClassNotFoundException : org. junit.platform.launcher.TestExecutionListener 运行 JUnit5 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51322862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com