-
pom添加依赖
xml<dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-datasource-nacos</artifactId> </dependency> -
添加nacos配置
yamlspring: cloud: sentinel: datasource: ds: nacos: server-addr: 127.0.0.1:8848 # namespace: public # 注意public空间下不能显示的设置为public否则获取不到配置 dataId: sentinel-client-app-sentinel.json groupId: DEFAULT_GROUP data-type: json rule-type: flow -
编写Controller测试Sentinel
java@RestController @RequestMapping("/sentinel/datasource") public class SentinelDatasourceController { @GetMapping("/index") @SentinelResource("sentinelDatasourceIndex") public String index(){ return "hello world index" ; } } -
nacos中添加dataId为sentinel-client-app-sentinel.json的配置
json[ { "resource": "sentinelDatasourceIndex", "limitApp": "default", "grade": 1, "count": 1, "strategy": 0, "controlBehavior": 0, "clusterMode": false } ] -
注意如果在namespace为public下创建的配置,则编写配置时namespace必须为空
sentinel持久限流化化规则到nacos
yicj2023-09-16 11:59
相关推荐
m0_662577971 分钟前
模板编译期哈希计算m0_662577971 分钟前
C++代码静态检测阿贵---1 分钟前
编译器命令选项优化add45a2 分钟前
分布式计算C++库「QT(C++)开发工程师」4 分钟前
C++并发编程新纪元:线程库、异步操作与泛型Lambda深度解析-许平安-7 分钟前
MCP项目笔记四(Transport)Felven7 分钟前
C. Stable Groups码农的小菜园7 分钟前
Java线程池学习笔记SuperEugene8 分钟前
Vue3 + Element Plus 表单校验实战:规则复用、自定义校验、提示语统一,告别混乱避坑|表单与表格规范篇2401_894241928 分钟前
基于C++的数据库连接池