java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

下載了最新的JUnit版本,是4.13,結果嘗試使用發現總是報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.2中沒有hamcrest包了

解決方案

  • 換成junit-4.8.jar

  • junit-4.12.jar + hamcrest-core-1.3.jar

發佈了339 篇原創文章 · 獲贊 238 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章