【问题标题】:Spring cloud gateway cannot find Fluent Java Routes APISpring Cloud Gateway 找不到 Fluent Java Routes API
【发布时间】:2018-08-09 15:09:24
【问题描述】:

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

@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。不确定我是否错过了什么。我正在使用 spring boot 2.0.0.M7 并且我有 spring-cloud-starter-gateway 依赖。

有什么想法吗?

【问题讨论】:

    标签: spring-boot spring-cloud spring-cloud-gateway


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 2019-12-06
    • 2021-01-24
    • 2021-03-27
    • 2021-11-29
    • 2019-06-10
    • 2019-12-26
    • 2020-10-21
    • 2019-01-09
    • 2016-12-10
    相关资源
    最近更新 更多