在多个网关实例间共享路由
Spring Cloud Gateway 提供了两种 RouteDefinitionRepository 实现。第一种是 InMemoryRouteDefinitionRepository,它仅存在于单个 Gateway 实例的内存中。这种类型的 Repository 不适合在多个 Gateway 实例之间同步路由。
为了在 Spring Cloud Gateway 集群实例之间共享路由,可以使用 RedisRouteDefinitionRepository。要启用此类存储库,必须将以下属性设置为 true:spring.cloud.gateway.redis-route-definition-repository.enabled。与 RedisRateLimiter 过滤器工厂类似,它需要使用 spring-boot-starter-data-redis-reactive Spring Boot 启动器。