快速接入sentinel文档:https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel
- 引入jar包
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
- 配置文件增加配置:
#设置sentinel控制台地址
spring.cloud.sentinel.transport.port=8719
spring.cloud.sentinel.transport.dashboard=http://localhost:8080
或者
spring:
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:8080
这里的配置会在应用服务器上开启一个Http Server端口为8719,与指定地址的sentinel控制台(localhost:8080)交互,传输限流规则数据等。
#开启sentinel
feign.sentinel.enabled=true
- Sentinel 对Feign、RestTemplate支持
Sentinel适配了Feign组件。
如果想使用,除了引入 spring-cloud-starter-alibaba-sentinel 的依赖外