参考博客:https://blog.csdn.net/ttzommed/article/details/90669320
原文中编写FunSentinelFeign类时,由于SentinelInvocationHandler方法的构造函数并不是public修饰

return new SentinelInvocationHandler(target, dispatch, funFallbackFactory),会报错。修改为使用反射调用
//获取指定的构造方法
Constructor<SentinelInvocationHandler> constructor = SentinelInvocationHandler.class.
getDeclaredConstructor(Target.class, Map.class, FallbackFactory.class);
constructor.setAccessible(true);
return constructor.newInstance(target, dispatch, new FallbackFactory.Default(fallbackInstance));
demo地址:gitee
最后
以上就是温柔老虎最近收集整理的关于Spring Cloud使用Sentinel做为Feign的熔断器之Fallback统一处理的全部内容,更多相关Spring内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复