java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.util.MockUtil
2017-12-13 00:00
5944 查看
摘要: 引入的包冲突,由于客户使用的spring boot版本(使用了客户的仓库),和我们项目中使用的版本不一样,导致包冲突。
错误信息记录:
maven 包冲突图:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/9c5064e79f75053d61eb061ff0cdfbcf.png)
解决办法:
就是降版本,具体操作:
一、去除spring boot 对该包的依赖
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/84a5d8e2e9be8775edefbc80ef981d40.png)
二、去除客户本地环境对该包的依赖
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/d46ca1b69899d1e6f9c812522f892e60.png)
三、重新引入该包
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/8af6b3f401bae87500a1b3594968da53.png)
四、查看解决冲突后的包依赖关系图
错误信息记录:
java.lang.NoClassDefFoundError: Could not initialize class org.mockito.internal.util.MockUtil at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:108) at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:69) at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:55) at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.afterTestMethod(ResetMocksTestExecutionListener.java:50) at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:319) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:94) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
maven 包冲突图:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/9c5064e79f75053d61eb061ff0cdfbcf.png)
解决办法:
就是降版本,具体操作:
一、去除spring boot 对该包的依赖
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/84a5d8e2e9be8775edefbc80ef981d40.png)
二、去除客户本地环境对该包的依赖
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/d46ca1b69899d1e6f9c812522f892e60.png)
三、重新引入该包
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/8af6b3f401bae87500a1b3594968da53.png)
四、查看解决冲突后的包依赖关系图
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/12/181d3377ab08dbda2160bfb77559b2c5.png)
相关文章推荐
- java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.m
- java.lang.NoClassDefFoundError: Could not initialize class org.jfree.ch
- java.lang.NoClassDefFoundError: Could not initialize class com.cyj.util.Jdbc
- java.lang.NoClassDefFoundError: Could not initialize class net.sf.json.util.JSONUtils
- Junit 抛出错误 java.lang.NoClassDefFoundError: Could not initialize class org.springframework.test.conte
- java.lang.NoClassDefFoundError: Could not initialize class com.zzxgy.struts.model.HibernateUtil
- java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart
- java.lang.NoClassDefFoundError: Could not initialize class org.springframework.beans.factory.BeanCre
- Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.threadpool.ThreadPool
- java.lang.NoClassDefFoundError: Could not initialize class com.liv.util.Hibe
- java.lang.NoClassDefFoundError: Could not initialize class org.springframework.beans.factory.BeanCre
- java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.el.ELContextImpl
- java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.AnnotationConfiguration
- java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.jackson.map.ObjectMapper
- java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.engine.Configurat
- 用DBCP进行数据连接池连接的时候出现java.lang.NoClassDefFoundError: Could not initialize class com.sujianbo.util.JdbcUtils_DBCP
- Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.fusesource
- java.lang.NoClassDefFoundError: Could not initialize class net.sf.json.util.JSONUtils
- java.lang.NoClassDefFoundError: Could not initialize class
- with root cause java.lang.NoClassDefFoundError:Could not initialize class com.AlipaySubmit