JUnit-4.13使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误


今天重新复习spring的时候,调用Junit架包来进行测试,进入其官网  https://junit.org/junit5/,点击右上角的Junit4进行查看

2.出现了的页面是这个样子

 

我把这个页面上的二个jar的下载下来了,并且还加载到了IDEA里面,没想到还是报错误,

java.lang.NoClassDefFoundError

当时笔者也是相当的犯难,毕竟很久没接触java的里面的一些东西,不是很有印象了,而且还是在一个新的编译器上面编译很多的操作都是是懂非懂。后来在看文档中终于找到了解决的方法。

去官网又看了一下,结果发现这样一段话:

 

 

  • junit.jar: Includes the Hamcrest classes. The simple all-in-one solution to get started quickly.Starting with version 4.11, Hamcrest is no longer included in this jar.
  • junit-dep.jar: Only includes the JUnit classes but not Hamcrest. Lets you use a different Hamcrest version.

   

  解决的方案如下:

(1) 换用更小版本的jar包,如4.8.jar

  (2 )  junit-4.12.jar + hamcrest-core-1.3.jar

   

笔者用的第二种方案


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM