错误信息

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

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. gnuplot设置字体及大小

    set term png font 'times.ttf,14'set fontpath '/home/peter/.fonts'set output 'vel-cost.eps'set gridse ...

  2. redis位操作

    setbit 设置指定key的偏移量处的值 key:键值 offset:二进制数据的偏移量(注意从左开始为第0位) value:要设置的值(0或1) getbit 获取对应key的offset处的值 ...

  3. 【入门必看】不理解「对象」?很可能有致命bug:简单的Python例子告诉你

    简介:越来越多的人要在学习工作中用到『编程』这个工具了,其中很大一部分人用的是Python.大部分人只是做做简单的科研计算.绘图.办公自动化或者爬虫,但-- 这就不需要理解「指针与面向对象」了吗? 在 ...

  4. Impala的count(distinct QUESTION_ID) 与ndv(QUESTION_ID)

    在impala中,一个select执行多个count(distinct col)会报错,举例: select C_DEPT2, count(distinct QUESTION_BUSI_ID) as ...

  5. JSP 的 4 种作用域?

    page:代表与一个页面相关的对象和属性. request:代表与客户端发出的一个请求相关的对象和属性.一个请求可能跨越多个页面,涉及多个 Web 组件:需要在页面显示的临时数据可以置于此作用域. s ...

  6. 有关em的个人理解

    个人的感觉关键就是在那个font-size,  对于一开始没有设置font-size的可以默认那就是16px  后面的所有的基础都应该是在前面距离他最近的那个font-size的大小作为1em进行设置 ...

  7. 【Linux】使用笔记

    前言 搜狗输入法,作为我体验最好的一个输入法,一直陪我从小学走到了现在,优麒麟线上发布会时,搜狗团队代表用"聪明"来形同它,事实也确实如此,它能十分人性地记录使用者常用的热词,并且 ...

  8. AtCoder Beginner Contest 187 F - Close Group

    题目链接 点我跳转 题目大意 给你一张完全图,你可以删除任意数量的边 要求删除完后剩余的所有子图必须是完全图 问完全子图数量最少是多少 解题思路 定义 \(ok[i]\) 表示状态为 \(i\) 时所 ...

  9. spark常用提交任务的基本的参数配置

    #!/bin/bash #队列名 根据yarn的队列提交 realtime_queue=root #提交的任务名 my_job_name="OrderQZ" spark-shell ...

  10. VirtualBox安装ubuntu 开发环境 配置

    一 下载VirtualBox安装程序以及ubuntu光盘镜像 1.下载VirtualBox安装程序(本文选用的是6.0.12版本) 建议从清华大学镜像站 https://mirrors.tuna.ts ...