sentinel1.8.0规则持久化nacos控制台改造

一、控制台改造
完整代码: link.
参考官方文档:link.
源码改造部分:
sentinel1.8.0规则持久化nacos控制台改造_第1张图片
sentinel1.8.0规则持久化nacos控制台改造_第2张图片

1.sidebar.html 流控规则路由从 dashboard.flowV1 改成 dashboard.flow 即可
2.application.properties增加配置nacos.addr=ip:port
3.pom.xml文件改造
sentinel1.8.0规则持久化nacos控制台改造_第3张图片
在这里插入图片描述

二、项目使用:
添加依赖:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2.2.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>


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

加入配置:

spring.cloud.sentinel.transport.port=8720
#spring.cloud.sentinel.transport.dashboard=xxx:8083
spring.cloud.sentinel.transport.dashboard=localhost:8080

spring.cloud.sentinel.datasource.flow.nacos.server-addr=xxx:8848
spring.cloud.sentinel.datasource.flow.nacos.data-id=${
     spring.application.name}-flow-rules
spring.cloud.sentinel.datasource.flow.nacos.group-id=SENTINEL_GROUP
spring.cloud.sentinel.datasource.flow.nacos.data-type=json
spring.cloud.sentinel.datasource.flow.nacos.rule-type=flow

spring.cloud.sentinel.datasource.degrade.nacos.server-addr=xxx:8848
spring.cloud.sentinel.datasource.degrade.nacos.data-id=${
     spring.application.name}-degrade-rules
spring.cloud.sentinel.datasource.degrade.nacos.group-id=SENTINEL_GROUP
spring.cloud.sentinel.datasource.degrade.nacos.data-type=json
spring.cloud.sentinel.datasource.degrade.nacos.rule-type=degrade

spring.cloud.sentinel.datasource.system.nacos.server-addr=xxx:8848
spring.cloud.sentinel.datasource.system.nacos.data-id=${
     spring.application.name}-system-rules
spring.cloud.sentinel.datasource.system.nacos.group-id=SENTINEL_GROUP
spring.cloud.sentinel.datasource.system.nacos.data-type=json
spring.cloud.sentinel.datasource.system.nacos.rule-type=system

spring.cloud.sentinel.datasource.authority.nacos.server-addr=xxx:8848
spring.cloud.sentinel.datasource.authority.nacos.data-id=${
     spring.application.name}-authority-rules
spring.cloud.sentinel.datasource.authority.nacos.group-id=SENTINEL_GROUP
spring.cloud.sentinel.datasource.authority.nacos.data-type=json
spring.cloud.sentinel.datasource.authority.nacos.rule-type=authority

spring.cloud.sentinel.datasource.param-flow.nacos.server-addr=xxx:8848
spring.cloud.sentinel.datasource.param-flow.nacos.data-id=${
     spring.application.name}-param-flow-rules
spring.cloud.sentinel.datasource.param-flow.nacos.group-id=SENTINEL_GROUP
spring.cloud.sentinel.datasource.param-flow.nacos.data-type=json
spring.cloud.sentinel.datasource.param-flow.nacos.rule-type=PARAM_FLOW

你可能感兴趣的:(sentinel,nacos,java)