springcloud 配置集成 Sentinel 限流器

1.下载Sentinel

您可以从 官方 GitHub Release 页面 页面下载最新版本的控制台 JAR 包。

https://github.com/alibaba/Sentinel

以当前版本 sentinel-dashboard-1.8.1.jar 为例

下载后,放到系统硬盘

同目录下创建bat文件 run.bat,内容为:

java -Dserver.port=8002 -Dcsp.sentinel.dashboard.server=localhost:8002 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar

双击运行

run.bat, 启动sentinel控制台

浏览器访问  http://localhost:8002/#/login

用户名密码均为:sentinel

2.客户端配置Sentinel

POM

 <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
 </dependency>

修改配置文件

扫描二维码关注公众号,回复: 12925328 查看本文章
#java项目www.fhadmin.org
#sentinel连接控制台
spring.cloud.sentinel.transport.dashboard=localhost:8002
#开启Feign对Sentinel的支持
feign.sentinel.enabled=true

根据业务需求在处理类上加上注解

增加 @Component 注解

注意,只有当请求过此带有@Component注解的处理类时,Sentinel控制台才有数据


猜你喜欢

转载自blog.51cto.com/14622073/2673906