[报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路 您所在的位置:网站首页 df314故障 [报错解决](Error Creating bean with name ‘xxx‘)类问题解决思路

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

2024-02-13 23:19| 来源: 网络整理| 查看: 265

遇到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,这种情况的具体原因暂时不清楚。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有