소스 검색

feat:测试Sentinel + Nacos整合,在Nacos进行Sentienl限流规则的持久化,从Naocs中读取限流规则

yang yi 1 년 전
부모
커밋
add2c55713
2개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      member-service-consumer/pom.xml
  2. 10 0
      member-service-consumer/src/main/resources/application.yaml

+ 5 - 0
member-service-consumer/pom.xml

@@ -16,6 +16,11 @@
         <maven.compiler.target>17</maven.compiler.target>
     </properties>
     <dependencies>
+        <!--导入Sentinel整合Nacos进行Sentinel规则持久化的依赖-->
+        <dependency>
+            <groupId>com.alibaba.csp</groupId>
+            <artifactId>sentinel-datasource-nacos</artifactId>
+        </dependency>
         <!--导入Sentinel依赖-->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>

+ 10 - 0
member-service-consumer/src/main/resources/application.yaml

@@ -14,6 +14,16 @@ spring:
       transport:
         dashboard: localhost:8080
         port: 8719
+      datasource:
+        #配置一个数据源,规则持久化的数据源
+        ds1:
+          nacos:
+            server-addr: localhost:8848
+            dataId: Sentinel-config.json
+            groupId: SENTINEL_GROUP
+            data-type: json
+            rule-type: flow
+
 feign:
   sentinel:
     #配置OpenFein整合Sentinel