Sentinel入门与进阶:微服务流量控制的最佳实践 ( 六 )

8.Gateway 整合 Sentinel(熔断、限流)

8.1.引入依赖

在 Spring Cloud Alibaba 2.1.6之前的版本,引入的是 sentinel-spring-cloud-gateway-adapter 包,并且需要自己实现好多配置类,2.1.6 之后的版本内部已经帮我们实现好了,所以使用起来比较简单了。

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!--2.1.6之前的版本是 adapter 的包,整合比较麻烦,需要写配置类-->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>

8.2.配置 application.yml

需要 配置的是 gateway 和 sentinel

        
 server:
  port: 19999       
 spring:
  application:
    name: sentinel-gateway
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
        namespace: 10001
        group: DEFAULT_GROUP 
    gateway:   #配置gateway
      discovery:
        locator:
          lowerCaseServiceId: true
          enabled: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值