目录
背景
在之前我们了解的Spring Cloud Gateway配置路由方式有两种方式
- spring:
- cloud:
- gateway:
- routes:
- - id: test
- predicates:
- - Path=/ms/test/*
- filters:
- - StripPrefix=2
- uri: http://localhost:9000
复制代码- @Bean
- public RouteLocator routeLocator(RouteLocatorBuilder builder) {
- return builder.routes()
- .route(r -> r.path("/ms/test/**")
- .filters(f -> f.stripPrefix(2))
- .uri("http://localhost:9000"))
- .build();
- }
复制代码但是遗憾的是这两种方式都不支持动态路由,都需要重启服务。 所以我们需要对Spring Cloud Gateway进行改造,在改造的时候我们就需要看看源码了解下Spring Cloud Gateway的路由加载 |