Java. lang. NoClassDefFoundError: org/hamcrest/SelfDescribing error reported by JUnit-4.11 use

Source: Internet
Author: User

Try to use JUnit today and download the latest JUnit version, which is 4.11. lang. noClassDefFoundError: An error such as org/hamcrest/SelfDescribing. I checked it online. The general solution is to change to a lower version. Some people say that the hamcrest package is missing. I went to the official website and looked at it again. I found the following:

  • 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 encoded in this jar.
  • Junit-dep.jar: Only allowed des the JUnit classes but not Hamcrest. Lets you use a different Hamcrest version.

Pay attention to the Black and underlined parts. Note: There is no hamcrest package in 4.1.1 and I don't know what the author thinks.

The best solution is:

Use is a package import solution:Junit. jar + hamcrest-core.jar + hamcrest-library.jar

Or:Junit-dep.ajr + hancrest-all.jar

Although the two import methods avoid repeated packages, they still encounter conflicts during use. After checking the various types and documents in the package, we found that some classes (such as assertions is () appear at org. hamcrest. mathchers and org. hamcrest. core, you need to pay attention when using it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.