Eclipse 报错 org.springframework.context.support.AbstractApplicationContext refresh处理

报错情况

复制代码
1月 08, 2021 6:14:16 下午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [beanPostProcessorExample] for bean with name 'helloWorld' defined in class path resource [Beans.xml]; nested exception is java.lang.ClassNotFoundException: beanPostProcessorExample
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [beanPostProcessorExample] for bean with name 'helloWorld' defined in class path resource [Beans.xml]; nested exception is java.lang.ClassNotFoundException: beanPostProcessorExample
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1382)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:663)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:630)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1491)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1014)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:828)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:865)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:548)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
    at beanPostProcessorExample.MainApp.main(MainApp.java:7)
Caused by: java.lang.ClassNotFoundException: beanPostProcessorExample
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:275)
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:437)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1430)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1374)
    ... 10 more
复制代码

 工程文件

 

 

 

错误原因

在看到报错信息中

java.lang.ClassNotFoundException: beanPostProcessorExample

 

我查看了所有用到该包的代码,最后发现Beans.xml中的class属性缺失类名

 

 于是我补充了类名

 

运行成功!

 

 

 

结论:查看错误信息内造成原因(Caused by ...),如果是缺失类,可以查看所有用到类的代码,添加即可。

 

posted @   影落潮生0  阅读(4292)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 对象分配(Alloc)底层原理浅谈
· 聊一聊 C#异步 任务延续的三种底层玩法
· 敏捷开发:如何高效开每日站会
· 为什么 .NET8线程池 容易引发线程饥饿
· golang自带的死锁检测并非银弹
阅读排行:
· 2024年终总结:5000 Star,10w 下载量,这是我交出的开源答卷
· 一个适用于 .NET 的开源整洁架构项目模板
· AI Editor 真的被惊到了
· API 风格选对了,文档写好了,项目就成功了一半!
· 【开源】C#上位机必备高效数据转换助手
点击右上角即可分享
微信分享提示