springcloud-alibaba-Sentinel
一.下载地址
**Tags · alibaba/Sentinel (github.com) **
二.添加依赖
com.alibaba.csp
sentinel-datasource-nacos
1.7.2
com.alibaba.cloud
spring-cloud-starter-alibaba-sentinel
2.2.6.RELEASE
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
2.1.0.RELEASE
三.配置yml
server:
port: 8401
spring:
application:
name: cloudalibaba-sentinel-service
cloud:
nacos:
discovery:
server-addr: localhost:8848 #配置nacos地址
sentinel:
transport:
# 配置sentinel-dashboard地址
dashboard: localhost:8080
# 默认8719端口,假如端口被占用会自动从8719开始依次+1扫描,直到找到没被占用的端口
port: 8719
#消费者将要去访问微服务的名称(成功注册进nacos的微服务提供者)
management:
endpoints:
web:
exposure:
include: '*'
四.启动类
@SpringBootApplication
@EnableDiscoveryClient
public class Mainapp8401 {
public static void main(String[] args) {
SpringApplication.run(Mainapp8401.class,args);
}
}
五.controller
@RestController
public class sentinelController {
@GetMapping("/testA")
public String testA(){
return "testA";
}
@GetMapping("/testB")
public String testB(){
return "testB";
}
}
六.访问端口
先访问 localhost:8401/testA
在进入Sentinel界面
七.流控,降级,熔断
图片太多不展示了.