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

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

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

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

 

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

当时笔者也是相当的犯难,毕竟很久没接触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

   

笔者用的第二种方案

相关文章:

  • 2021-07-15
  • 2022-12-23
  • 2021-10-09
  • 2021-11-12
  • 2022-12-23
  • 2022-01-19
  • 2021-08-01
猜你喜欢
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2021-12-29
  • 2021-08-30
相关资源
相似解决方案