-
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
相关推荐
karry_k5 小时前
MyBatis批量insert-select踩坑:useGeneratedKeys=true 可能让PostgreSQL返回大量插入结果karry_k6 小时前
PostgreSQL 在 MyBatis 中执行正常 SQL 失效:一次 DELETE USING 踩坑记录SamDeepThinking9 小时前
从源码到代码:MyBatis-Flex 与 MyBatis-Plus 的逐项对比她的男孩12 小时前
Spring Boot 接 Flowable 工作流:用 3 个注解搭一个请假审批流程荣码14 小时前
LLM结构化输出:让AI返回JSON而不是废话,我踩了4个坑plainGeekDev15 小时前
Gson → kotlinx.serialization小bo波1 天前
Java Swing 图形用户界面实验 —— 从算术练习到游戏开发的完整实践咖啡八杯1 天前
GoF设计模式——备忘录模式