使用junit-4.12.jar进行单元测试出现java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误处理

junit-4.12.jar缺少hamcrest包,导入hamcrest-core-1.3.jar包即可

若使用intellij idea则在.iml配置文件中添加

<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />

即可


C:\Users\admin\.jdks\corretto-1.8.0_452\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.6\lib\idea_rt.jar=56653" -javaagent:C:\Users\admin\AppData\Local\JetBrains\IntelliJIdea2024.3\captureAgent\debugger-agent.jar -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -Ddebugger.agent.enable.coroutines=true -Dkotlinx.coroutines.debug.enable.flows.stack.trace=true -Dkotlinx.coroutines.debug.enable.mutable.state.flows.stack.trace=true -Dfile.encoding=UTF-8 -classpath "D:\r\org\junit\platform\junit-platform-launcher\1.3.2\junit-platform-launcher-1.3.2.jar;D:\r\org\apiguardian\apiguardian-api\1.0.0\apiguardian-api-1.0.0.jar;D:\r\org\junit\platform\junit-platform-engine\1.3.2\junit-platform-engine-1.3.2.jar;D:\r\org\junit\platform\junit-platform-commons\1.3.2\junit-platform-commons-1.3.2.jar;D:\r\org\opentest4j\opentest4j\1.1.1\opentest4j-1.1.1.jar;D:\r\org\junit\vintage\junit-vintage-engine\5.7.0\junit-vintage-engine-5.7.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.6\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.6\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2024.3.6\plugins\junit\lib\junit-rt.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\charsets.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\access-bridge-64.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\cldrdata.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\dnsns.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\jaccess.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\jfxrt.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\localedata.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\nashorn.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\sunec.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\sunjce_provider.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\sunmscapi.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\sunpkcs11.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\ext\zipfs.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\jce.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\jfr.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\jfxswt.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\jsse.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\management-agent.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\resources.jar;C:\Users\admin\.jdks\corretto-1.8.0_452\jre\lib\rt.jar;D:\UserData\Desktop\数据库开发基础-MySQL\basic-spring-boot\target\test-classes;D:\UserData\Desktop\数据库开发基础-MySQL\basic-spring-boot\target\classes;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-validation\2.1.14.RELEASE\spring-boot-starter-validation-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter\2.1.14.RELEASE\spring-boot-starter-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot\2.1.14.RELEASE\spring-boot-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.1.14.RELEASE\spring-boot-autoconfigure-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.1.14.RELEASE\spring-boot-starter-logging-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\admin\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\admin\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;C:\Users\admin\.m2\repository\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;C:\Users\admin\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\admin\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\admin\.m2\repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;C:\Users\admin\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.34\tomcat-embed-el-9.0.34.jar;C:\Users\admin\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.19.Final\hibernate-validator-6.0.19.Final.jar;C:\Users\admin\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\admin\.m2\repository\org\jboss\logging\jboss-logging\3.3.3.Final\jboss-logging-3.3.3.Final.jar;C:\Users\admin\.m2\repository\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.1.14.RELEASE\spring-boot-starter-web-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.1.14.RELEASE\spring-boot-starter-json-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.10.4\jackson-databind-2.9.10.4.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.10\jackson-annotations-2.9.10.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.10\jackson-core-2.9.10.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.10\jackson-datatype-jdk8-2.9.10.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.10\jackson-datatype-jsr310-2.9.10.jar;C:\Users\admin\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.10\jackson-module-parameter-names-2.9.10.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.1.14.RELEASE\spring-boot-starter-tomcat-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.34\tomcat-embed-core-9.0.34.jar;C:\Users\admin\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.34\tomcat-embed-websocket-9.0.34.jar;C:\Users\admin\.m2\repository\org\springframework\spring-web\5.1.15.RELEASE\spring-web-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-beans\5.1.15.RELEASE\spring-beans-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-webmvc\5.1.15.RELEASE\spring-webmvc-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-context\5.1.15.RELEASE\spring-context-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-expression\5.1.15.RELEASE\spring-expression-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.1.14.RELEASE\spring-boot-starter-aop-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-aop\5.1.15.RELEASE\spring-aop-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\aspectj\aspectjweaver\1.9.5\aspectjweaver-1.9.5.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-actuator\2.1.14.RELEASE\spring-boot-starter-actuator-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.1.14.RELEASE\spring-boot-actuator-autoconfigure-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-actuator\2.1.14.RELEASE\spring-boot-actuator-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\io\micrometer\micrometer-core\1.1.13\micrometer-core-1.1.13.jar;C:\Users\admin\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;C:\Users\admin\.m2\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar;C:\Users\admin\.m2\repository\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-test\2.1.14.RELEASE\spring-boot-starter-test-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-test\2.1.14.RELEASE\spring-boot-test-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.1.14.RELEASE\spring-boot-test-autoconfigure-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;C:\Users\admin\.m2\repository\net\minidev\json-smart\2.3\json-smart-2.3.jar;C:\Users\admin\.m2\repository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;C:\Users\admin\.m2\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;C:\Users\admin\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\admin\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\admin\.m2\repository\org\assertj\assertj-core\3.11.1\assertj-core-3.11.1.jar;C:\Users\admin\.m2\repository\org\mockito\mockito-core\2.23.4\mockito-core-2.23.4.jar;C:\Users\admin\.m2\repository\net\bytebuddy\byte-buddy\1.9.16\byte-buddy-1.9.16.jar;C:\Users\admin\.m2\repository\net\bytebuddy\byte-buddy-agent\1.9.16\byte-buddy-agent-1.9.16.jar;C:\Users\admin\.m2\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;C:\Users\admin\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\admin\.m2\repository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;C:\Users\admin\.m2\repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;C:\Users\admin\.m2\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;C:\Users\admin\.m2\repository\org\springframework\spring-core\5.1.15.RELEASE\spring-core-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-jcl\5.1.15.RELEASE\spring-jcl-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-test\5.1.15.RELEASE\spring-test-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\xmlunit\xmlunit-core\2.6.4\xmlunit-core-2.6.4.jar;C:\Users\admin\.m2\repository\mysql\mysql-connector-java\8.0.20\mysql-connector-java-8.0.20.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.1.14.RELEASE\spring-boot-starter-data-jpa-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.1.14.RELEASE\spring-boot-starter-jdbc-2.1.14.RELEASE.jar;C:\Users\admin\.m2\repository\com\zaxxer\HikariCP\3.2.0\HikariCP-3.2.0.jar;C:\Users\admin\.m2\repository\org\springframework\spring-jdbc\5.1.15.RELEASE\spring-jdbc-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\javax\transaction\javax.transaction-api\1.3\javax.transaction-api-1.3.jar;C:\Users\admin\.m2\repository\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;C:\Users\admin\.m2\repository\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;C:\Users\admin\.m2\repository\org\hibernate\hibernate-core\5.3.17.Final\hibernate-core-5.3.17.Final.jar;C:\Users\admin\.m2\repository\javax\persistence\javax.persistence-api\2.2\javax.persistence-api-2.2.jar;C:\Users\admin\.m2\repository\org\javassist\javassist\3.23.2-GA\javassist-3.23.2-GA.jar;C:\Users\admin\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\admin\.m2\repository\org\jboss\jandex\2.0.5.Final\jandex-2.0.5.Final.jar;C:\Users\admin\.m2\repository\org\dom4j\dom4j\2.1.3\dom4j-2.1.3.jar;C:\Users\admin\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.4.Final\hibernate-commons-annotations-5.0.4.Final.jar;C:\Users\admin\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.1\jaxb-runtime-2.3.1.jar;C:\Users\admin\.m2\repository\org\glassfish\jaxb\txw2\2.3.1\txw2-2.3.1.jar;C:\Users\admin\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.7\istack-commons-runtime-3.0.7.jar;C:\Users\admin\.m2\repository\org\jvnet\staxex\stax-ex\1.8\stax-ex-1.8.jar;C:\Users\admin\.m2\repository\com\sun\xml\fastinfoset\FastInfoset\1.2.15\FastInfoset-1.2.15.jar;C:\Users\admin\.m2\repository\org\springframework\data\spring-data-jpa\2.1.17.RELEASE\spring-data-jpa-2.1.17.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\data\spring-data-commons\2.1.17.RELEASE\spring-data-commons-2.1.17.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-orm\5.1.15.RELEASE\spring-orm-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-tx\5.1.15.RELEASE\spring-tx-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\springframework\spring-aspects\5.1.15.RELEASE\spring-aspects-5.1.15.RELEASE.jar;C:\Users\admin\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.7.0\junit-jupiter-api-5.7.0.jar;C:\Users\admin\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\admin\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\admin\.m2\repository\org\junit\platform\junit-platform-commons\1.3.2\junit-platform-commons-1.3.2.jar;C:\Users\admin\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.7.0\junit-jupiter-engine-5.7.0.jar;C:\Users\admin\.m2\repository\org\junit\platform\junit-platform-engine\1.3.2\junit-platform-engine-1.3.2.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 com.tplink.nbu.demo.basicspringboot.controller.UserLogInOutControllerTest 九月 02, 2025 2:22:58 下午 org.junit.platform.launcher.core.DefaultLauncher handleThrowable 警告: TestEngine with ID 'junit-vintage' failed to discover tests java.lang.NoClassDefFoundError: org/junit/platform/engine/support/discovery/SelectorResolver at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:63) at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:168) at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:155) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.support.discovery.SelectorResolver at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 10 more 九月 02, 2025 2:22:58 下午 org.junit.platform.launcher.core.DefaultLauncher handleThrowable 警告: TestEngine with ID 'junit-jupiter' failed to discover tests java.lang.NoClassDefFoundError: org/junit/platform/engine/support/discovery/SelectorResolver at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69) at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:168) at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:155) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.support.discovery.SelectorResolver at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 10 more 进程已结束,退出代码为 0
最新发布
09-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值