返回

[报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路

发布时间:2022-12-02 03:15:55 700
# spring# sql# apache# 扫描

遇到Error Creating bean with name ’ '这类问题的解决思路

错误日志关键部分:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productHandler': Unsatisfied dependency expressed through field 'productMapper'; nested exception is 

org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'xxxMapper' defined in file [xxxMapper.class]:
Unsatisfied dependency expressed through bean property 'sqlSessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactoryBean' defined in class path resource [xxxConfig.class]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [xxx\mappers\testMapper.xml]';

nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 文件提前结束。

大意如下:不满足依赖异常。创建名为’xxxMapper’的bean时出错:通过字段’sqlSessionFactory’表达的不满足的依赖项;

一、配置与扫描问题:

spring配置文件中检查包是否扫描,仔细检查自己的配置文件里和相关的配置路径。

在项目配置文件(xxxConfig.class)中的配置:


[报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路_xml

在application.yml文件中的配置:


[报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路_spring_02

或者检查一下启动类上的注解配置:


[报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路_spring_03

二、注解问题:

Controller、service层的注解缺失会造成创建bean时出现错误。

@Controller

@Service

三、依赖包缺失,检查pom配置文件

检查pom.xml文件下是否缺失依赖或者有多余的依赖,判断是否对bean的正常创建有影响。

四、xml包中存在空文件:

[报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路_xml_04

在xxxMapper.xml的包中如果有空的xml文件,就会造成此Bug,这种情况的具体原因暂时不清楚。

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
ASP.NET中获取URL重写前的原始地址 2022-12-02 02:46:37