一。整合ribbon
在SpringCloud Alibaba微服务中的nacos中其实已经集成了ribbon的依赖:

所以我们只需要引入nacos的依赖即可:
<!--springcloud alibb sentinel依赖 1.7版本依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
其余步骤与spring cloud整合ribbon操作基本一致,有兴趣的小伙伴可以参照我的另外一篇博客:
SpringCloud微服务中使用RestTemplate+Ribbon实现负载均衡(实现方法+实现原理+替换负载均衡策略)
二。整合openFeign
在SpringCloud Alibaba微服务中Sentinel整合openFeign需要在application.yml配置文件中开启对Feign的支持:
#对Feign的支持
feign:
sentinel:
enabled: true
其余步骤与spring cloud整合ribbon操作基本一致,有兴趣的小伙伴可以参照我的另外一篇博客:
Spring Cloud微服务使用OpenFeign实现调用其他模块接口方法
最后
以上就是冷静钢笔最近收集整理的关于SpringCloud Alibaba微服务中Sentinel整合ribbon+openFeign的全部内容,更多相关SpringCloud内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复