SpringCloud Alibaba微服务中Sentinel整合ribbon+openFeign

一。整合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实现调用其他模块接口方法

猜你喜欢

转载自blog.csdn.net/weixin_44009447/article/details/113565621