6

#yyds干货盘点# springcloud整合Sentinel使用Nacos存储规则

 3 years ago
source link: https://blog.51cto.com/u_13321676/4937408
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

#yyds干货盘点# springcloud整合Sentinel使用Nacos存储规则

原创

灰太狼_cxh 2022-01-17 11:40:42 博主文章分类:springcloud学习系列 ©著作权

文章标签 spring 文章分类 Java 编程语言 阅读数334

springcloud整合Sentinel使用Nacos存储规则, 在​ ​#yyds干货盘点# springcloud整合Sentinel实现接口限流 ​​基础代码上进行修改。

1.代码实现:

<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
<version>1.5.2</version>
</dependency>

yml配置

spring:
application:
name: sentinel

cloud:
sentinel:
transport:
dashboard: localhost:8080
datasource:
ds:
nacos:
server-addr: localhost:8848 #nacos的地址
dataId: ${spring.application.name}-sentinel
groupId: DEFAULT_GROUP
data-type: json
rule_type: flow

server:
port: 8001

2.实现效果:

启动nacos,浏览器打开​ ​http://localhost:8848/nacos​​登录后再配置管理中的配置列表进行添加规则

#yyds干货盘点# springcloud整合Sentinel使用Nacos存储规则_spring

启动sentinel-dashboard,浏览器打开​ ​http://localhost:8080/​​ 使用默认用户密码:sentinel进行登录

#yyds干货盘点# springcloud整合Sentinel使用Nacos存储规则_spring_02

启动sentinel项目,浏览器打开​ ​http://localhost:8001/index​​, 然后刷新sentinel控制台页面,可以看到在nacos配置的规则在sentinel中的流控规则页面显示。

#yyds干货盘点# springcloud整合Sentinel使用Nacos存储规则_spring_03


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK