在项目中快速整合sentinel
在项目中整合sentinel
- 导入jar包
<!--加入sentinel-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!--加入actuator-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
添加Sentinel后,会暴露/actuator/sentinel端点http://localhost:8080/actuator/sentinel
而Springboot默认是没有暴露该端点的,所以我们需要自己设置
server:
port: 8080
management:
endpoints:
web:
exposure:
include: '*'
需要整合Sentinel-dashboard(哨兵流量卫兵)
下载地址:https://github.com/alibaba/Sentinel/releases
-
第一步:执行 java -jar sentinel-dashboard-1.7.0.jar 启动(就是一个Springboot工程)
-
第二步: 访问我们的sentinel控制台(1.6版本加入登陆页面) http://127.0.0.1:8080/
默认账号密码 sentinel/sentinel -
第三步:我们的微服务04-ms-alibaba-sentinel-order 也整合好了sentinel,我们也搭建 好了Sentinel控制台了,临门一脚 为微服务添加sentinel的控制台地址
spring:
cloud:
sentinel:
transport:
dashboard: localhost:8080