ALearner

  • 首页
  • Python
  • Linux
  • Java
  • 工具
  • 前端
  • 算法
  • My World
HelloStranger
每个人都是初学者
  1. 首页
  2. 工具
  3. 正文

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

2017年10月18日 8035点热度 1人点赞 0条评论

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

  • 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.

注意黑色加下划线的部分。说明4.1.1中没有hamcrest包了.

maven项目中解决方法 ,完整pom:

<!--单元测试工具 start-->
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>4.11</version>
 <scope>test</scope>
 </dependency>
 <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
 <dependency>
 <groupId>org.hamcrest</groupId>
 <artifactId>hamcrest-all</artifactId>
 <version>1.3</version>
 <scope>test</scope>
 </dependency>
 <!--单元测试工具 end-->

 

相关

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2017年10月18日

iquantumer

你现在的态度决定你十年后是人物还是废物。

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2022 alearner.top. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

鲁ICP备16024047号