Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiUserController': Unsatisfied dependency expressed through field 'apiMutiHttpClientUtil'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.crt.openapi.utils.ApiMutiHttpClientUtil' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Description:

Field apiMutiHttpClientUtil in com.crt.openapi.apiinterface.controller.base.CommonController required a bean of type 'com.crt.openapi.utils.ApiMutiHttpClientUtil' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'com.crt.openapi.utils.ApiMutiHttpClientUtil' in your configuration.

总是提示无法注入Service或者Dao中的Bean!

后来经研究发现,SpringBoot项目的Bean装配默认规则是根据Application类所在的包位置从上往下扫描!

“Application类”是指SpringBoot项目入口类。这个类的位置很关键:

如果Application类所在的包为:com.demo.module,则只会扫描com.demo.module包及其所有子包,如果service或dao所在包不在com.demo.module及其子包下,则不会被扫描!

所以需在application启动类中加上

@MapperScan("com.*.dao")//加上你项目的dao或service所在文件位置即可

@SpringBootApplication

springboot available: expected at least 1 bean which qualifies as autowire candidate奇葩问题的更多相关文章

  1. Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate

    项目使用spring, mybatis.因为分了多个模块,所以会这个模块引用了其它模块的现在,结果使用Junit测试的时候发现有两个模块不能自动注入dao和service问题.解决后在此记录一下. 解 ...

  2. spring加载bean报错:expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

    看具体报错日志: 警告: Unable to proxy interface-implementing method [public final void cn.wlf.selection.proto ...

  3. NoSuchBeanDefinitionException:No qualifying bean of type found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.

    报错如下: NoSuchBeanDefinitionException:No qualifying bean of type   found for dependency: expected at l ...

  4. No matching bean of type [xx] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency

    这个看起来很弱爆的问题其实是因为其他的配置文件中已经出现了为xx定义好的注入.如果用@Autowired就会得到上面的错误 , 但是用@Resource的时候就会看到类似下面的错误 Bean name ...

  5. mybatis expected at least 1 bean which qualifies as autowire candidate for this dependency

    错误原因:没有引入相应mapper接口,导致spring没有找到依赖 解决方法一:使用注解的方法: 首先在spring配置文件中添加 <bean class="org.mybatis. ...

  6. NoSuchBeanDefinitionException: No qualifying bean of type 'com.bj186.ssm.mapper.EmployeeMapper' available: expected at least 1 bean which qualifies as autowire candidate

    在搭建SSM spring springmvc  mybatis整合的时候, 遇到了这个问题 说说我的问题吧!我在进行单元测试的时候,出现了这个错误,网上一查才知道是,配置文件中没有写扫描包信息.一看 ...

  7. 【java异常】expected at least 1 bean which qualifies as autowire candidate for this depende

    1.查看接口实现类是否加入注解,如service.repository等 2.查看spring配置文件是否自动扫描包    <context:component-scan base-packag ...

  8. org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut

    spring中一个符号的错误居然让我浪费了四五个小时才找出来,不得不给自己了两个耳光.. 由于新建项目与原来项目的目录结构有所不同,copy过来的配置文件,有些地方修改的不彻底,导致spring扫描注 ...

  9. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.thinkplatform.dao.UserLogDao' available: expected at least 1 bean which qualifies as autowi

    我出错的问题是: 检查:

随机推荐

  1. springboot集成spring security安全框架入门篇

    一. :spring security的简介 Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下 ...

  2. 基于Nginx实现反向代理

    一.nginx的简介 Nginx 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务 其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服 ...

  3. Mybatis更新和删除数据

    接上文->Mybatis快速入门<- 1.在UserMapper.xml配置更新和删除 <!-- 更新操作--> <update id="update" ...

  4. Spring-AOP底层实现

    1.aop的底层实现:通过spring提供的动态代理技术实现的,在运行期间,spring通过动态代理技术动态的生成代理对象,代理对象方法执行时增强功能的介入,再去调用目标对象的方法,从而完成功能的增强 ...

  5. 想减少代码量,快设置一个有感知的 Aware Spring Bean

    摘要:正常情况下,Spring 中的 Bean 对 Spring 是无感知的,Spring 框架提供了这种扩展能力,能让一个 bean 成为有感知的. 本文分享自华为云社区<有感知的 Aware ...

  6. typescript使用入门及react+ts实战

    ts介绍 TypeScript是一种由微软开发的自由和开源的编程语言.它是 JavaScript 的一个超集,而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程. 与js关系 ts与js区 ...

  7. Python 报错 ValueError list.remove(x) x not in list 解决办法

    平时开发 Python 代码过程中,经常会遇到这个报错: ValueError: list.remove(x): x not in list 错误提示信息也很明确,就是移除的元素不在列表之中. 比如: ...

  8. baiyang网站二代域名及短链接

    http://985.so/wesv https://cloud.tencent.com/developer/column/93900

  9. python selenium 多个页面对象类使用同一个webdriver(即只打开一个浏览器窗口)

    1 class BasePage(): 2 """selenium基类""" 3 4 def __init__(self, driver=N ...

  10. Java枚举类与常用方法

    小简博客 - 小简的技术栈,专注Java及其他计算机技术.互联网技术教程 (ideaopen.cn) 枚举类 如何创建 首先,从名字就可以看出,枚举是一个类,那么我们就可以直接在创建时选择枚举就可以. ...