JUnit4.12使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误解决方法

从错误提示可以看出没有hamcrest包中的类

在这里插入图片描述
网上提供的方案
导入包的方案:junit.jar+ hamcrest-core.jar + hamcrest-library.jar
自己解决成功方案:在有junit-4.12.jar的情况下,导入hamcrest-core-1.3.jar便可以成功运行了。
maven项目可以:

<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
</dependency>
<!-- junit包 -->
<dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-all</artifactId>
      <version>1.3</version>
</dependency>

附上jar包下载链接:https://download.youkuaiyun.com/download/imaniy/10688368

事后分析一下原理

发现:junit使用了hamcrest框架。junit-4.12.jar没有这个框架hamcrest,需要自己导入。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值