让sentinel-dashboard的流控配置持久化到nacos

以sentinel-1.7.0为例

下载源码,idea打开。

找到sentinel-dashboard这个项目

在该项目下的pom.xml文件中找到:

        <!-- for Nacos rule publisher sample -->
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-datasource-nacos</artifactId>
            <scope>test</scope>
        </dependency>

将<scope>test</scope>注释掉。

 

展开test->java->com.alibaba.csp.sentinel.dashboard->rule->nacos

复制NacosConfig到src->java->com.alibaba.csp.sentinel.dashboard->config

复制其余3个文件到src->java->com.alibaba.csp.sentinel.dashboard->rule

 

打开src->java->com.alibaba.csp.sentinel.dashboard->controller->v2->FlowControllerV2

@Qualifier("flowRuleDefaultProvider") 改为 @Qualifier("flowRuleNacosProvider")

@Qualifier("flowRuleDefaultPublisher") 改为 @Qualifier("flowRuleNacosPublisher")

 

打开src->webapp->resources->app->scripts->directives->sidebar->sidebar.html

注释掉

      <li ui-sref-active="active" ng-if="!entry.isGateway">
<a ui-sref="dashboard.flowV1({app: entry.app})">
<i class="glyphicon glyphicon-filter"></i>&nbsp;&nbsp;流控规则</a>
</li>

解除

<li ui-sref-active="active" ng-if="entry.appType==0">
<a ui-sref="dashboard.flow({app: entry.app})">
<i class="glyphicon glyphicon-filter"></i>&nbsp;&nbsp;流控规则 V1</a>
</li>
将描述 流控规则 V1 改为 流控规则 V2

通过sentinel-dashboard项目打开Terminal,输入mvn clean package

在target目录下会生成我们需要的sentinel-dashboard.jar

posted @ 2019-11-21 14:46  wintersoft  阅读(3472)  评论(0编辑  收藏  举报