-
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
相关推荐
cmpxr_2 分钟前
【C】原码和补码以及环形坐标取模算法2401_8274999915 分钟前
python项目实战09-AI智能伴侣(ai_partner_5-6)PD我是你的真爱粉17 分钟前
MCP 协议详解:从架构、工作流到 Python 技术栈落地win x38 分钟前
Redis 使用~如何在Java中连接使用redis星晨雪海44 分钟前
基于 @Resource 的支付 Service 多实现类完整示例阿维的博客日记1 小时前
什么是逃逸分析ACP广源盛139246256731 小时前
破局 Type‑C 切换器痛点@ACP#GSV6155+LH3828/GSV2221+LH3828 黄金方案Ricky_Theseus1 小时前
C++右值引用Rick19932 小时前
Java内存参数解析我是大猴子2 小时前
Spring代理类为何依赖注入失效?