1.在gateway服务模块中添加gateway整合sentinel的依赖
<!--sentinel整合gateway的依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!--sentinel的依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
2. 在application.yml配置文件中添加sentinel控制台的配置
sentinel: #sentinel的配置
transport:
dashboard: localhost:8080 #配置sentinel dashboard地址
port: 8719 #默认端口8719
3. 编写gateway配置类,自定义限流配置
package com.mc.tutor.config;
import com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
import com.alibaba.csp.sentinel.adapter.gateway.common.