有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在spring cloud gateway中实现Redis速率限制?

我正在尝试在spring云网关中设置速率限制

我试图在应用程序中配置过滤器。yaml如下所示

filters:
    - name: RequestRateLimiter
      args:
         redis-rate-limiter.replenishRate: 1
         redis-rate-limiter.burstCapacity: 5

我得到下面的错误

java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name RequestRateLimiter

如何在spring云网关中实现速率限制


共 (1) 个答案

  1. # 1 楼答案

    其中一种可能性是不包含以下依赖项(我第一次犯的错误)

    org.springframework.boot:spring-boot-starter-data-redis-reactive
    

    由于args包含redis-rate-limiter,因此必须使用此依赖项

    下面是IDE的一个屏幕截图,显示了当包含上述依赖项时RequestRateLimiterGatewayFilterFactory正在被添加

    enter image description here