本文介绍sentinel的直接流控的使用。
0、环境
- jdk 1.8
- sentinel 1.8.2
- springboot 2.4.2
1、sentinel环境搭建
从官方发布的网站上下载: sentinel Jar,下载对应版本。
下载完成后,进入刚才下载的Jar文件所在的目录,执行如下命令:
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.2.jar
正常启动后,浏览器访问: http://localhost:8080,显示sentinel登录页面,用户名和密码默认都是sentinel。到这里,sentinel就搭建完成了。
2、集成sentinel
引入依赖:
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel