sentinel依赖
<!--Sentinel 限熔断流-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
nacos依赖
<!--Spring Cloud Alibaba-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--用于Sentinel持久化-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
application.yml配置
server:
port: 8010
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
spring:
datasource:
url: jdbc:mysql://192.168.40.66:3306/tcp_store?useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
application:
#服务名称 nacos服务列表里的服务名
name: account-service
cloud:
nacos:
discovery:
#nacos地址
server-addr: 192.168.40.66:8848
ip: 192.168.40.1
sentinel:
transport:
dashboard: 192.168.40.66:8858
client-ip: 192.168.40.1
eager: true
datasource:
ds:
nacos:
serverAddr: 192.168.40.66:8848
dataId: account-service-sentinel
groupId: DEFAULT_GROUP
dataType: json
ruleType: FLOW
nacos配置
[
{
"resource": "getByCode",
"limitApp": "default",
"grade": 1,
"count": 3,
"strategy": 0,
"controlBehavior": 0,
"clusterMode": false
}
]