错误信息

今天开发的过程中突然出现如下错误:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.smilx.ipayment.dao.XkioskFileMapper' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1716)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1272)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1226)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
... 63 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ipaymentCheckController':
Unsatisfied dependency expressed through field 'XkioskFileMapper';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'com.smilx.ipayment.dao.SmilxXkioskFileMapper' available: expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)

 以上错误信息大致意思是:No qualifying bean of type 'com.smilx.ipayment.dao.XkioskFileMapper' available 这个dao层的mapper 依赖注入失败!

分析及解决办法:

     既然是注入失败首先要检查的就是扫描 Mapper 接口和容器管理配置,Dao层的路径是否配置正确!

然后检查是否有重名的Bean!

还有可能在@Service注解的类中直接使用Spring注入的对象,导致加@Service注解的类创建Bean不成功,如下

    @Autowired
private CommonPropertiesUtil util;
@Autowired
private CommonService commonService; String SECRET_SEX = util.getSecretSex()//直接使用的注入对象util;
String SECRET_USER = util.getSecretUser();

  把String SECRET_USER = util.getSecretUser()从类中移到方法中运行正常了!

在这里把自己遇到的问题和解决方案做个记录备份,希望也能解决你的问题

还有其他情况欢迎评论讨论!

当spring 对象@Autowired 注入失败或者创建对象Bean失败、No qualifying bean/Error creating bean 的失败情形分析和解决方案的更多相关文章

  1. Failed to load ApplicationContext ,Error creating bean with name 'adminUserService': Injection of autowired dependencies failed;

    Druid配置的时候出现这个问题: "C:\Program Files\Java\jdk1.8.0_191\bin\java" -ea -Didea.test.cyclic.buf ...

  2. Error creating bean with name 'unMblTotController': 注入失败

    今天新来的小伙子,进公司做项目,然后自己新建了包,出了以下错误 y.UnsatisfiedDependencyException: Error creating bean with name 'unM ...

  3. eclipse 启动tomcat报Spring错误 Error creating bean with name 'serviceOrderBiz': Injection of autowired dependencies failed

    启动tomcat报异常,提示Sring无法创建serviceOrderBiz(第一行红字),继续看是因为有一个自动注入的字段无法注入ModuleInterfaceBiz(第二行红字),检查servic ...

  4. Error creating bean with name 'menuController': Injection of autowired dependency……

    出现了一大串错误 Error creating bean with name 'userController': Injection of autowired dependencies failed. ...

  5. Error creating bean with name 'adminUserController': Injection of autowired dependencies failed;

    spring 个坑爹地,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ...

  6. Error creating bean with name 'com.you.user.dao.StudentDaoTest': Injection of autowired dependencies

    1.错误叙述性说明 七月 13, 2014 6:37:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadB ...

  7. Error creating bean with name 'signController': Injection of autowired dependencies failed

    出现了一大串错误,Error creating bean with name 'signController': Injection of autowired dependencies failed. ...

  8. Error creating bean with name 'com.you.user.dao.StudentDaoTest': Injection of autowired dependencies

    1.错误描述 七月 13, 2014 6:37:41 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBean ...

  9. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0'

    七月 05, 2018 10:26:54 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRul ...

随机推荐

  1. 六个步骤,从零开始教你搭建基于WordPress的个人博客

    摘要:WordPress是使用PHP语言开发的博客平台,是免费开源的.用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站,也可以把WordPress当作一个内容管理系统(CMS)来使用 ...

  2. Wordpress Polylang 翻译自定义格式

    WordPress 多语言插件 Polylang 主题函数参考 重要:使用一个函数之前,你必须检查函数是否存在,否则,你的网站可能会在 Polylang 更新之前遇到致命错误(因为 WordPress ...

  3. 基于Layuimini的自己封装后台模板

    基于Layui的后台模板,正在开发中 交流qq群:1062635741 邮箱:zhangqueque.foxmail.com GitHub:https://github.com/ZhangQueque ...

  4. Java 面试知识点【背诵版 240题 约7w字】

    -- 转载自牛客网 是瑶瑶公主吖 Java 基础 40 语言特性 12 Q1:Java 语言的优点? ① 平台无关性,摆脱硬件束缚,"一次编写,到处运行". ② 相对安全的内存管理 ...

  5. 【剑指offer】03 从尾到头打印链表

    题目地址:从尾到头打印链表 题目描述                                    输入一个链表,按链表从尾到头的顺序返回一个ArrayList. 时间限制:C/C++ 1秒, ...

  6. C# 两个时间相减 计算两个时间差(年月日时分秒)

    DateTime dt1; DateTime dt2; int days=(dt2.Date-dt1.Date).Days;   或者 TimeSpan ts = dt2 -dt1;          ...

  7. vue watch监听不到对象,探究 watch 原理

    最近使用vue watch时,在某些模块监听不到对象的改变,无法触发回调函数. 解决: 使用watch监听对象时,只能监听到该对象初始化时已存在的key值. 如下例监听user对象,在初始化时没有ag ...

  8. java如何实现入职时间到现在 java如何计算知道入职时间, 求工作时长格式为年--月--日。

    Date ruZhi = new Date("入职年月bai"); Date now = new Date(); //算出du来时间夸格zhi多长 long shiChang = ...

  9. eclipse中安装Springboot的插件

    1help在Eclipse Marketplace中搜索spring-tool-suite,点击install,然后接受协议,等待重启eclipse即可

  10. 基于websocket的netty demo

    前面2文 基于http的netty demo 基于socket的netty demo 讲了netty在http和socket的使用,下面讲讲netty如何使用websocket websocket是h ...