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

来源:互联网 发布:linux互斥锁 实例 编辑:程序博客网 时间:2024/06/11 18:40

下载了最新的JUnit版本,是4.11,结果尝试使用发现总是报java.lang.NoClassDefFoundError:org/hamcrest/SelfDescribing这样的错误,上网查了一下,一般的解决方案是,换一个低一点的版本就好了。还有人说,是缺少hamcrest的包。去官网又看了一下,结果发现这样一段话:

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

注意黑色加下划线的部分。说明4.1.1中没有hamcrest包了,不知道作者是怎么想的。

 

最好的解决方法是:

(1)换成junit-4.8.jar

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



原文出处:http://blog.sina.com.cn/s/blog_818e7be601019nq1.html

0 0