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

遇到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)中的配置:

在application.yml文件中的配置:

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

二、注解问题:

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

@Controller

@Service

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

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

四、xml包中存在空文件:

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

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值