赞
踩
先引入Maven 依赖
- <dependency>
- <groupId>com.alibaba.csp</groupId>
- <artifactId>sentinel-datasource-nacos</artifactId>
- </dependency>
在线上环境中,我们的项目中,肯定会配置多种流控规则,这样就需要项目拉取多个数据源
- spring:
- cloud:
- sentinel:
- eager: true
- transport:
- port: 8719
- dashboard: 127.0.0.1:8088
- datasource:
- # 多个数据源配置,nacos config
- ds1:
- nacos:
- server-addr: 127.0.0.1:8848
- dataId: ${spring.application.name}-flow-rules
- groupId: DEFAULT_GROUP
- data-type: json
- rule-type: flow #规则类型
- namespace: admin
- username: admin
- password: 123456
- ds2: #自定义名称 要求唯一
- nacos:
- server-addr: 127.0.0.1:8848
- dataId: ${spring.application.name}-param-rules
- groupId: DEFAULT_GROUP
- data-type: json
- rule-type: flow #规则类型
- namespace: admin
- username: admin
- password: 123456
- ds3: #自定义名称 要求唯一
- nacos:
- server-addr: 127.0.0.1:8848
- dataId: ${spring.application.name}-system-rules
- groupId: DEFAULT_GROUP
- data-type: json
- rule-type: flow #规则类型
- namespace: fceb1a18-f30b-411e-84ef-491596eca67c
- username: wxj_test
- password: 123456
- ds4: #自定义名称 要求唯一
- nacos:
- server-addr: 127.0.0.1:8848
- dataId: ${spring.application.name}-authority-rules
- groupId: DEFAULT_GROUP
- data-type: json
- rule-type: flow #规则类型
- namespace: admin
- username: admin
- password: 123456
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。