测试报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

测试报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错

junit-4.12.jar换了一个项目,在以前可以使用在现在这个不能使用一直出现java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing异常 差点奔溃
在这里插入图片描述
后来发现是junit-4.12.jar版本的原因 ,把junit-4.12.jar换成junit-4.10.jar得到了解决

原因;

从4.11版本开始,Hamcrest不再包含在jar.junit-dep中。jar:只包含JUnit类,但不包括Hamcrest。允许您使用不同的Hamcrest版本。
所以使用4.11版本以上的会出现这个异常

解决方案

  1. 添加hamcrest-core-1.3.jar
  2. 把unit版本降低到unit-4.10.ja

资源

hamcrest-core-1.3.jar
链接:https://pan.baidu.com/s/1xo2KKJfpkl7hiy47oIFNEA 
提取码:a6fi 
unit-4.10.jar
链接:https://pan.baidu.com/s/1bXfO7ateO5c-z5rUltlEYg 
提取码:0hor
发布了135 篇原创文章 · 获赞 12 · 访问量 5457

猜你喜欢

转载自blog.csdn.net/weixin_45736498/article/details/105373217