Spring cloud gateway cannot find Fluent Java Routes API



我正在尝试使用Spring-cloud-gateway。在浏览文档时,我发现我们不仅可以在 yml/属性文件中配置路由,还可以使用 Fluent Routes API。这是文档中的代码片段。

@Bean
public RouteLocator customRouteLocator(ThrottleGatewayFilterFactory throttle) {
    return Routes.locator()
            .route("test")
                .predicate(host("**.abc.org").and(path("/image/png")))
                .addResponseHeader("X-TestHeader", "foobar")
                .uri("http://httpbin.org:80")
            .route("test2")
                .predicate(path("/image/webp"))
                .add(addResponseHeader("X-AnotherHeader", "baz"))
                .uri("http://httpbin.org:80")
            .route("test3")
                .order(-1)
                .predicate(host("**.throttle.org").and(path("/get")))
                .add(throttle.apply(tuple().of("capacity", 1,
                     "refillTokens", 1,
                     "refillPeriod", 10,
                     "refillUnit", "SECONDS")))
                .uri("http://httpbin.org:80")
            .build();
}

但是我找不到这个班级Routes.不知道我是否错过了什么。我正在使用弹簧靴2.0.0.M 7,并且包括spring-cloud-starter-gateway depependecy。

知道吗?

Routes不再

可用。将RouteLocatorBuilder参数添加到customRouteLocator 。我会修复文档。

最新更新