使用nacos实现sentinel规则持久化

1.pom

<!--SpringCloud ailibaba sentinel-datasource-nacos 后续做持久化用到-->
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-datasource-nacos</artifactId>
        </dependency>

2.yml

server:
  port: 8401

spring:
  application:
    name: cloudalibaba-sentinel-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848 #Nacos服务注册中心地址
    sentinel:
      transport:
        dashboard: localhost:8080 #配置Sentinel dashboard地址
        #默认从8719开始 没有被占用了就往后面扫描直到找到
        port: 8719
        #持久化配置 spring.cloud.sentinel.datasource...
      datasource:
        ds1:
          nacos:
            server-addr: localhost:8848
            dataId: cloudalibaba-sentinel-service #nacos配置的名字
            groupId: DEFAULT_GROUP
            data-type: json
            rule-type: flow

management:
  endpoints:
    web:
      exposure:
        include: '*'

feign:
  sentinel:
    enabled: true # 激活Sentinel对Feign的支持



3.nacos添加配置 这里选json
在这里插入图片描述

在这里插入图片描述

4.启动就实现了持久化配置

猜你喜欢

转载自blog.csdn.net/qq_45432665/article/details/114095626