Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘queryOrderService’: Unsatisfied dependency expressed through field ‘ebaServApi’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.taikang.wechat.remote.api.EbaServApi’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
网上查找的问题:
1.注入问题
有两个类实现了xx,所以spring不知道该绑定哪个类,就抛出了错误
解决办法:使用@Qualifie注解,表明哪个类是我们需要的
2.service或dao所在包未被扫描到
SpringBoot项目的Bean装配默认规则是根据Application类所在的包位置从上往下扫描,如果Application类所在的包为:com.demo.module,则只会扫描com.demo.module包及其所有子包,如果service或dao所在包不在com.demo.module及其子包下,则不会被扫描
解决办法:在application启动类中加上@MapperScan注解,加上你项目的dao或service所在文件位置即可
3.service循环依赖
解决办法:排除循环依赖即可
我遇到的问题:
4.@FeignClient(name = “”, url = “${config.eba.url}”)读取配置时无法读取到这个配置
解决办法:去把配置添加上