开发者社区 > 云原生 > 正文

ClassNotFoundException类未找到异常

2021-02-12 22:35:54.629 INFO 19272 --- [ main] com.tanhua.sso.MyApplication : Starting MyApplication on LAPTOP-2FM8GH4Q with PID 19272 (D:\CODE\my-code\my-tanhua\my-tanahua-sso\target\classes started by Elgin in D:\CODE\my-code\my-tanhua) 2021-02-12 22:35:54.638 INFO 19272 --- [ main] com.tanhua.sso.MyApplication : No active profile set, falling back to default profiles: default 2021-02-12 22:35:56.176 INFO 19272 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2021-02-12 22:35:56.180 INFO 19272 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode. 2021-02-12 22:35:56.243 INFO 19272 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33ms. Found 0 repository interfaces. 2021-02-12 22:35:56.722 ERROR 19272 --- [ main] o.s.boot.SpringApplication : Application run failed

java.lang.IllegalStateException: Cannot load configuration class: org.apache.rocketmq.spring.autoconfigure.ExtConsumerResetConfiguration at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:413) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:253) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:130) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar:2.1.0.RELEASE] at com.tanhua.sso.MyApplication.main(MyApplication.java:12) [classes/:na] Caused by: java.lang.IllegalStateException: Unable to load cache item at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:130) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:315) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:137) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:109) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:402) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] ... 12 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/apache/rocketmq/client/consumer/DefaultLitePullConsumer at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_121] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_121] at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_121] at org.springframework.cglib.core.ReflectUtils.addAllMethods(ReflectUtils.java:443) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.proxy.Enhancer.getMethods(Enhancer.java:632) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:667) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanFactoryAwareGeneratorStrategy.generate(ConfigurationClassEnhancer.java:252) ~[spring-context-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:354) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:106) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:104) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_121] at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] ... 20 common frames omitted Caused by: java.lang.ClassNotFoundException: org.apache.rocketmq.client.consumer.DefaultLitePullConsumer at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121] ... 36 common frames omitted

在启动spring boot项目中报错提示找不到或无法加载主类.

原提问者GitHub用户Elgin-xj

展开
收起
芬奇福贵 2023-05-26 11:08:55 226 0
1 条回答
写回答
取消 提交回答
  • 原因没有找到DefaultLitePullConsumer的类,检查一下是否项目中引入了其他rocketmq client版本,造成maven依赖冲突,最终使用了低版本的rocketmq客户端,导致缺失该类。

    另一个方法是降级RocketMQ-Spring的版本,在最新的2.2.0才引入了DefaultLitePullConsumer。

    原回答者GitHub用户RongtongJin

    2023-05-26 17:26:06
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载