项目场景:

学习feign+hystrix熔断进行远程调用


问题描述

启动远程调用类时会出现bug

Caused by: java.lang.IllegalStateException: No fallback instance of type class org.springblade.demo.feign.BlogClientFallback found for feign client blade-demoat org.springblade.core.cloud.sentinel.BladeFeignSentinel$Builder$1.getFromContext(BladeFeignSentinel.java:103)at org.springblade.core.cloud.sentinel.BladeFeignSentinel$Builder$1.create(BladeFeignSentinel.java:87)at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:64)at feign.Feign$Builder.target(Feign.java:269)at org.springframework.cloud.openfeign.HystrixTargeter.target(HystrixTargeter.java:38)at org.springframework.cloud.openfeign.HystrixTargeter$$FastClassBySpringCGLIB$$b9e5b0c6.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)at com.alibaba.cloud.sentinel.feign.SentinelTargeterAspect.process(SentinelTargeterAspect.java:44)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)at org.springframework.cloud.openfeign.HystrixTargeter$$EnhancerBySpringCGLIB$$f66027e.target(<generated>)at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:352)at org.springframework.cloud.openfeign.FeignClientFactoryBean.getTarget(FeignClientFactoryBean.java:388)at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:361)at org.springframework.cloud.openfeign.FeignClientsRegistrar.lambda$registerFeignClient$0(FeignClientsRegistrar.java:246)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1235)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)... 29 common frames omitted

原因分析:

看错误报告是没有fallback类的实例
所以首先需要在fallback类上加上@component注解,让spring生成一个bean。
如果添加@Component都无效,其实不是无效,只是扫描的包的路径不一样,如果我们自定义了自己的业务模块,命名不叫这个,那么配了@Component注解的fallback实例也是扫描不到的。因为SpringBoot默认扫描Application同级目录下的所有包。但是业务模块的包名不一致。


解决方案:

在远程调用启动类上面加上@ComponentScan(“xxx”)注解,
并且使用idea的Build > Rebuild Project, 而不是平时用的Build Project(Ctrl + F9), 可以解决问题. 原因是, Build只会编译被修改了的文件, 但这次, 涉及注解里的内容, 需要强行把所有的classes重新生成. 只有Rebuild Project才有这个效果.

No fallback instance of type class错误的解决方案相关推荐

  1. 【SpringBoot学习笔记】运行错误:No fallback instance of type class found for feign client

    [[报错情况:]] feign中使用Hystrix,报错:No fallback instance of type class  found for feign client [源码:] @Feign ...

  2. No fallback instance of type class found for feign client user-service(转)

    No fallback instance of type class found for feign client user-service(转) 1.错误日志 在 feign 开启熔断,配置 fal ...

  3. Visual Studio 2015打开ASP.NET MVC的View提示“Object reference not set to an instance of an object“错误的解决方案

    Visual Studio 2015打开ASP.NET MVC的View提示"Object reference not set to an instance of an object&quo ...

  4. No fallback instance of type class 回调处理类 found for feign client 被调用的类

    在springboot项目中使用feign组件时,出现异常如下 同时也配置了注解 但依然报错 原因:该启动类只能找到该包及其子类的注解,无法识别熔断处理类上的@Component注解,需要在启动类加上 ...

  5. Eclipse继承HttpServlet出现:HttpServlet cannot be resolved to a type的错误的解决方案

    显然是Eclipse找不到相应的包,即javax.servlet .错误如下: 解决方案如下: 1.打开tomcat所在的文件夹,然后打开apache-tomcat-8.5.43(即你的Apache版 ...

  6. Java变异出现错误:No enclosing instance of type XXX is accessible

    摘要:写java代码时遇到下面的编译错误. 本文分享自华为云社区<Java中出现No enclosing instance of type XXX is accessible问题>,作者: ...

  7. 语法错误:No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing

    错误 问题 No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing 没 ...

  8. No enclosing instance of type 错误的解决方法

    今天做练习的时候碰到的小问题: No enclosing instance of type Test02 is accessible. Must qualify the allocation with ...

  9. No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing

    No enclosing instance of type SmsUtils is accessible. Must qualify the allocation with an enclosing ...

最新文章

  1. asp.net断点续传技术
  2. JDBC 利用反射技术将查询结果封装为对象(简单ORM实现)
  3. 思科IPS系统的bypass mode
  4. request获取url的参数编码问题
  5. 若依如何解决请求地址存在中文出现异常?
  6. ARKit何以从同类技术中胜出?
  7. Docker教程小白实操入门(7)--基于Commit定制镜像
  8. 学习python菜鸟教程
  9. HTML5期末大作业:书店商城系统网站设计——响应式图书电商HTML 网上书店模板 (25页) HTML+CSS+JavaScript
  10. 计算机底层逻辑无法仿造大脑,重塑世界的底层逻辑|读《终极算法》
  11. ANSI-美国国家标准学会
  12. gitlab 注册runner
  13. [转]我奋斗了18年不是为了和你一起喝咖啡
  14. ios模拟器 安装ipa_安装ipa到模拟器
  15. 浙江省等保测评机构项目测评收费价格标准参考
  16. 计算机excel还原,3种方法找回电脑上已删除的Excel文档
  17. 【新华三】华三设备NTP无法同步
  18. 我的2020年度总结 “既往不恋,纵情向前”
  19. 建筑行业为什么要数字化转型?
  20. STM32F103读取SD卡的数据(fat文件模式)

热门文章

  1. Visulalize Boost Voronoi in OpenSceneGraph
  2. AI公开课:19.05.30 瞿炜-新东方AI研究院院长《做懂教育的AI:把未来带进现实》课堂笔记以及个人感悟
  3. 软件工程——(1)软件与软件工程 思维导图
  4. [学习笔记]数据与科学训练营之五:机器学习
  5. 64位ubantu 16.04.2系统安装谷歌浏览器过程
  6. 【电磁】基于Matlab模拟电偶极子电磁场附GUI界面
  7. springboot学习
  8. 服务器安全神器,Linux 上安装 Fail2Ban 保护 SSH
  9. 【评测】SF9/SF21昆虫细胞培养基
  10. 数据分析:大数据时代的必备技能之EXCEL