SSM整合时报错:java.lang.NoClassDefFoundError: org/springframework/core/ErrorCoded


今天在SSM整合调试时报了一个错误java.lang.NoClassDefFoundError,部分内容如下:

Mar 27, 2022 2:45:19 PM org.springframework.test.context.support.AbstractTestContextBootstrapper getDefaultTestExecutionListenerClassNames
INFO: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
Mar 27, 2022 2:45:19 PM org.springframework.test.context.support.AbstractTestContextBootstrapper getTestExecutionListeners
INFO: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@20322d26, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@192b07fd, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@64bfbc86, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@64bf3bbf, org.springframework.test.context.support.DirtiesContextTestExecutionListener@55d56113, org.springframework.test.context.transaction.TransactionalTestExecutionListener@148080bb, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@dc24521, org.springframework.test.context.event.EventPublishingTestExecutionListener@10bdf5e5]
Mar 27, 2022 2:45:19 PM org.springframework.test.context.TestContextManager prepareTestInstance
SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@64bf3bbf] to prepare test instance [MapperTest@52feb982]
java.lang.NoClassDefFoundError: org/springframework/core/ErrorCoded


Caused by: java.lang.ClassNotFoundException: org.springframework.core.ErrorCoded
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 57 more


java.lang.NoClassDefFoundError: org/springframework/core/ErrorCoded


Caused by: java.lang.ClassNotFoundException: org.springframework.core.ErrorCoded
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 57 more

Process finished with exit code -1

找了好久都没有找到问题出现在哪,最后查看依赖发现,我在引入spring-test依赖时发现里面也包含spring-core这个包,两个spring-core包版本不一致从而引发错误

 

 解决方法:

1、把spring-test的版本也更改为4.3.7

 

 2、刷新maven,这是可以看到两个spring-core的版本一致了

 

 3、再次进行调试,运行成功,问题解决

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM