今天尝试使用JUnit,下载了最新的JUnit版本,是4.11,结果尝试使用发现总是报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包了,不知道作者是怎么想的。

最好的解决方法是:

使用是导入包的方案:junit.jar
+ hamcrest-core.jar + hamcrest-library.jar

或者是:junit-dep.ajr+hancrest-all.jar

这两种导入方法虽然尽量避免了导入重复的包,但使用时还是遇到了冲突。查看包中各类和文档后发现有些类(例如:断言is())同时出现在了org.hamcrest.Mathchers和org.hamcrest.core中,则在用到时候引入的时候需要注意。

hamcrest.jar的下载地址是:https://code.google.com/p/hamcrest/downloads/list

JUnit-4.11使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误的更多相关文章

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

    原文引自: http://blog.csdn.net/castle07/article/details/8553704 今天尝试使用JUnit,下载了最新的JUnit版本,是4.11,结果尝试使用发现 ...

  2. 【Junit】JUnit-4.12使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

    下载了最新的JUnit版本,是4.12,结果尝试使用发现总是报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing这样的错误, 上网查 ...

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

    今天重新复习spring的时候,调用Junit架包来进行测试,进入其官网  https://junit.org/junit5/,点击右上角的Junit4进行查看 2.出现了的页面是这个样子 我把这个页 ...

  4. IntelliJ IDEA工具增加test测试方法,报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

    是因为我在IntelliJ IDEA中,通过plugins增加 插件的时候,在 增加的测试类是junit4.12,改版本的jar包不再包含hamcrest-library.jar .我是通过将自己的项 ...

  5. java.lang.NoClassDefFoundError:org/hamcrest/SelfDescribing

    1.错误描述 java.lang.NoClassDefFoundError:org/hamcrest/SelfDescribing 2.错误原因 将junit-4.11.jar导入到lib目录中,出现 ...

  6. java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing,

    缺少一个java包,然后我在这个网址找到了http://central.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1. ...

  7. 关于jsp web项目中的javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver错误

    错误: javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver org.apache.j ...

  8. javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/el/ELResolver错误解决办法

    今天不用eclipse.myeclipse等开发工具,纯手写JSP页面(有点作死)时突然出现以前从来没遇到过的问题,报错如下: HTTP Status 500 - java.lang.NoClassD ...

  9. IDEAL启动项目的时候报java.lang.NoClassDefFoundError: javax/servlet/Filter错误

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...

随机推荐

  1. C++线程类的封装

    简单的C++线程操作的封装,使用了智能指针管理对象的释放. 可运行对象基类 class SimpleRunable:public RefCountedBase { public: SimpleRuna ...

  2. Windows Phone 之手势识别(Flick)

    1. 引入dll (silverlight for wndows phone toolkit) 2.引入命名空间 01.xmlns:toolkit="clr-namespace:Micros ...

  3. linux上配置subversion服务器端安装配置并使用svn,windows本地检出,设置同步更新服务器的钩子

    参考http://my.oschina.net/junn/blog/164041 http://songxj.blog.51cto.com/620981/396113 http://5iwww.blo ...

  4. java 抓取百度根据关键词搜索域名

    package baidusearch; import com.sun.glass.ui.SystemClipboard; import java.util.*; import java.util.H ...

  5. MongoDB update数据语法【转】

    在前面的文章“mongodb 查询的语法”里,我介绍了Mongodb的常用查询语法,Mongodb的update操作也有点复杂,我结合自己的使用经验,在这里介绍一下,给用mongodb的朋友看看,也方 ...

  6. fineuploader 上传jquery 控件

    fineuploader 昨天用的一个jquery插件. 可参考这篇文章以前写的 file-uploader  跟 这个跟里面介绍的2个jquery 插件相比.觉得更强大写..版本号都3.9 了….. ...

  7. [BZOJ 1028] [JSOI2007] 麻将 【枚举+贪心判断】

    题目链接:BZOJ - 1028 题目分析 枚举听的是哪种牌,再枚举成对的是哪种牌,再贪心判断: 从1到n枚举每一种牌,如果这种牌的个数小于0,就返回不合法. 将这种牌的张数 % 3, 剩下的只能和 ...

  8. 【UVA11019】Matrix Matcher

    Description Given an N × M matrix, your task is to find the number of occurences of an X × Y pattern ...

  9. QSplashScreen开机画面(不断的repaint)

    QApplication a(argc, argv);    QPixmap pixmap(":/Image/start.png");//绑定启动图片    QSplashScre ...

  10. python2.7中使用mysql (windows XP)

    一.首先下载mysql—python模块,下载完毕之后会有一个MySQL-python-1.2.3.win32-py2.7.exe文件,点击安装一路next,ok. 二.编辑配置文件(setting. ...