我们首先来看一下报错信息

Description:

Field businessFeignClient in com.ysc.service.BusinessConfigService required a bean of type 'com.ysc.feignclient.BusinessFeignClient' 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.ysc.feignclient.BusinessFeignClient' in your configuration.

再来看一下 Feign 的配置信息

@SpringBootApplication(
scanBasePackages = "com.ysc",
exclude = {
DataSourceAutoConfiguration.class,
ThymeleafAutoConfiguration.class
})
@EnableFeignClients
public class Application { public static void main(String[] args) {
SpringApplication.run(Application.class, args);
} }

从表面上看配置并没有什么问题,那么我们来分析一下问题的具体原因。

注解 @EnableFeignClients 与 @ComponentScan 有冲突,两种注解都会搜索注入指定目录中的 bean 。@EnableFeignClients 引入了 FeignClientsRegistrar 类,实现了 Spring 的bean 资源的加载。

FeignClientsRegistrar中registerFeignClients方法获取了@EnableFeignClients注解中的basepackage 属性值,并进行注入。如果两种注解都使用时,其中@EnableFeignClients会覆盖 @ComponentScan 中指定的目录,从而恢复到默认目录。

如何解决这个问题:

1、可以将 FeignClient 这个 bean 放在和 Application 启动类同级目录

2、可以在 @EnableFeignClients中通过 clients 属性指定 bean 目录

@EnableFeignClients(clients = {
BusinessFeignClient.class
})

Spring Cloud 使用 FeignClient 启动报错的更多相关文章

  1. 笔记本电脑切换到无线热点无法联网问题&Spring Cloud相关工程启动报错问题

    通过禁用本地网络,和禁用另一个无线网络,以及禁用后重开,修改密码,重连的方式均失败后, 使用IE浏览器浏览提示失败,点击诊断,诊断出DNS服务器无响应异常. 突然想到通过ipconfig查看ip,网关 ...

  2. 【spring cloud】子模块启动报错com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect

    spring cloud子模块启动报错 Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanic ...

  3. spring cloud gateway网关启动报错:No qualifying bean of type 'org.springframework.web.reactive.DispatcherHandler'

    网关配置好后启动报错如下: org.springframework.context.ApplicationContextException: Unable to start web server; n ...

  4. Spring Cloud和eureka启动报错 解决版本依赖关系

    导读 An attempt was made to call a method that does not exist. The attempt was made from the following ...

  5. 使用CXF+Spring发布WebService,启动报错

    使用CXF+Spring发布WebService,启动报错,日志如下: 五月 12, 2017 9:01:37 下午 org.apache.tomcat.util.digester.SetProper ...

  6. 【spring cloud】【spring boot】项目启动报错:Cannot determine embedded database driver class for database type NONE

    解决参考文章:https://blog.csdn.net/hengyunabc/article/details/78762097 spring boot启动报错如下: Error starting A ...

  7. 【spring data jpa】启动报错:nested exception is java.util.NoSuchElementException

    spring boot项目中 使用spring data jpa 启动报错: org.springframework.beans.factory.UnsatisfiedDependencyExcept ...

  8. 【spring boot】整合LCN,启动spring boot2.0.3 启动报错:Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

    spring boot 2.0.3启动报错: Error starting ApplicationContext. To display the conditions report re-run yo ...

  9. 【spring boot】mybatis启动报错:Consider defining a bean of type 'com.newhope.interview.dao.UserMapper' in your configuration. 【Mapper类不能被找到】@Mapper 和@MapperScan注解的区别

    启动报错: 2018-05-16 17:22:58.161 ERROR 4080 --- Disconnected from the target VM, address: '127.0.0.1:50 ...

随机推荐

  1. 防火墙内JVisualVM连接jstatd解决方案

    jstatd启动后会打开两个端口,其中一个端口可通过参数“-p”指定,如果不指定默认为1099,另一个是一个随机端口,不能参数指定: # netstat -lpnt|grep jstatd tcp   ...

  2. Hdu1281 棋盘游戏

    棋盘游戏 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  3. Foundation-NSOperation-NSInvocationOperation/NSBlockOperation/NSOperationQueue

    iOS多线程编程技术之NSThread.Cocoa NSOperation.GCD 线程之间的通信 iOS开发系列--并行开发其实很容易 GCD由浅入深学习 iOS多线程NSOperation/Que ...

  4. hadoop和spark相关参数的配置

    背景 MapReduce和Spark对外提供了上百个配置参数,用户可以为作业定制这些参数以更快,更稳定的运行应用程序.本文梳理了最常用的一些MapReduce和Spark配置参数. MapReduce ...

  5. spark图解

    导语 spark 已经成为广告.报表以及推荐系统等大数据计算场景中首选系统,因效率高,易用以及通用性越来越得到大家的青睐,我自己最近半年在接触spark以及spark streaming之后,对spa ...

  6. Mahout简介

    Mahout简介 一.mahout是什么 Apache Mahout是ApacheSoftware Foundation (ASF)旗下的一个开源项目,提供了一些经典的机器学习的算法,皆在帮助开发人员 ...

  7. Tomcat数据源配置方法总结

    最近接触的数据表管理项目,涉及到了数据源配置,所以整理了一下配置方法: JNDI数据源统一都是在Tomcat下server.xml中配置的,根据应用范围的差别又分为一下几种方式: 第一种:配置单个应用 ...

  8. CSS 基础 例子 盒子模型及外边距塌陷

    我们通常设置的宽度和高度,是指盒子模型中内容(content)的宽度和高度.元素的高度,还要加上上下padding和上下border,元素整个盒子的高度还要加上上下margin:宽度类似计算. 注意: ...

  9. UNIGUI换版本注意事项

    比如UNIGUI换版本注意事项 许多人在更换UNIGUI版本时,会遇到各种问题,报各样错.比如下面的: 然后便不知所措,怀疑是UNIGUI新版本有问题——不能安装成功.其实不然. 下面是正确的解决方法 ...

  10. 设置UITableView分割线距左边的间距

    ``` [self.tableView setSeparatorInset:UIEdgeInsetsZero]; [self.tableView setLayoutMargins:UIEdgeInse ...