项目中加入sentinel
build.gradle
plugins {
id 'org.springframework.boot' version '2.6.11'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'maven'
}
group = 'com.emapgo'
archivesBaseName = 'hdmap4'
version = '1.0.0'
sourceCompatibility = '1.8'
repositories {
mavenLocal()
maven {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2021.0.4.0')
compile('com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2021.0.4.0')
compile('com.alibaba.cloud:spring-cloud-starter-alibaba-sentinel:2021.0.4.0')
compile('com.alibaba.csp:sentinel-transport-simple-http:1.8.6')
}
com.alibaba.cloud:spring-cloud-starter-alibaba-sentinel:2021.0.4.0
添加该包使项目支持sentinel熔断限流
com.alibaba.csp:sentinel-transport-simple-http:1.8.6
添加该包使服务与sentinel-dashboard通信
applicatoin.yaml
server:
port: 8080
spring:
cloud:
nacos:
config:
server-addr: 192.168.3.2:30848
namespace: dev
discovery:
register-enabled: true
server-addr: 192.168.3.2:30848
namespace: dev
group: test
service: provider
sentinel:
transport:
port: 8719
dashboard: 192.168.3.2:30880
config:
import:
- optional:nacos:hdmap4?group=test
port: sentinel-dashboard推送通信端口
dashboard: sentinel-dashboard服务地址和端口