Spring cloud gateway 结合 sentinel 总结

Spring cloud gateway 结合 sentinel 总结

  • Maven版本

    • Spring Cloud 版本 Hoxton.SR6
    • Spring Boot 版本 2.2.8.RELEASE
    • Spring Cloud Alibaba 版本 2.2.1.RELEASE

问题描述:

Spring Cloud Gateway项目在pom.xml导入Sentinel有关依赖后,Sentinel功能没有起作用(实时监控等功能不起作用):

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!--使用nacos 保存限流规则-->
<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-datasource-nacos</artifactId>
</dependency>

这里使用Nacos来保存限流规则。

解决方案:alibaba/spring-cloud-alibaba/issues/1378

可以在resources资源目录下新建SPI文件,
文件名:META-INF/services/com.alibaba.csp.sentinel.slotchain.SlotChainBuilder
文件内容:com.alibaba.csp.sentinel.adapter.gateway.common.slot.GatewaySlotChainBuilder

posted @ 2020-10-10 14:19  Zhifeng_Shen  阅读(345)  评论(0编辑  收藏  举报