首先出现的错误:java.lang.NoClassDefFoundError: org/hamcrest/TypeSafeMatcher exception
这是因为没有导入hamcrest包,导入这个包时,我导入了jmock下的hamcrest-library包,但是在运行的时候出现
新的错误:
org.hamcrest.TypeSafeMatcher"'s signer information does not match signer information of other classes in the same package
这时依照网上的做法是由于junit4中自带有一个hamcrest,所以调整junit4和hamcrest包的导入顺序,但是我试了不起作用;
这时,我导入另外一个包hamcrest-all-1.1.jar,
再进行包顺序的调整,把hamcret-all包放在junit4包的前面,即可。
本文详细阐述了解决Java项目中导入hamcrest包时出现的NoClassDefFoundError和TypeSafeMatcher签名不匹配错误的方法,通过调整hamcrest和junit4包的导入顺序,并引入hamcrest-all-1.1.jar包,成功解决了冲突问题。
1160

被折叠的 条评论
为什么被折叠?



