@SpringBootApplication
@EnableEurekaClient
@Configuration
public class GatewayApplication {
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("um_route", r -> r
.path("/um/**")
.uri("lb://user-management")
)
.build();
}
}
discovery.locator is enabled as:
spring.application.name=gateway
server.port=10002
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lower-case-service-id=true
application is registed:

ps:
it seems spring cloud gateway have a default config for the routing as /application-name/
so I got response by url http://localhost:10002/user-management/hello
But still don't know how to customize the routing url
You might try adding setPath("/hello") in routing
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
@ryanjbaxter
I am facing a similar problem, the loadbalancer is not able to retrieve the server list.
Error message:
2018-09-05 23:20:17.751 INFO 47037 --- [ctor-http-nio-2] c.netflix.loadbalancer.BaseLoadBalancer : Client: localhost instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=localhost,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2018-09-05 23:20:17.756 INFO 47037 --- [ctor-http-nio-2] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
2018-09-05 23:20:17.760 INFO 47037 --- [ctor-http-nio-2] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client localhost initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=localhost,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@107dc063
2018-09-05 23:20:17.822 ERROR 47037 --- [ctor-http-nio-2] .a.w.r.e.DefaultErrorWebExceptionHandler : Failed to handle request [GET http://localhost:8080/rest-service/hello]
org.springframework.cloud.gateway.support.NotFoundException: Unable to find instance for localhost
at org.springframework.cloud.gateway.filter.LoadBalancerClientFilter.filter(LoadBalancerClientFilter.java:72) ~[spring-cloud-gateway-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.gateway.handler.FilteringWebHandler$GatewayFilterAdapter.filter(FilteringWebHandler.java:133) ~[spring-cloud-gateway-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.gateway.filter.OrderedGatewayFilter.filter(OrderedGatewayFilter.java:44) ~[spring-cloud-gateway-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.cloud.gateway.handler.FilteringWebHandler$DefaultGatewayFilterChain.lambda$filter$0(FilteringWebHandler.java:115) ~[spring-cloud-gateway-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:45) ~[reactor-core-3.1.8.RELEASE.jar:3.1.8.RELEASE]
Service Registry:

Code:
_PS: Works fine when the actual endpoint is provided instead of the service id._
Closing this issue due to lack of requested feedback.
Closing this issue due to lack of requested feedback.
sorry feedback late:
here is my demo projects reproduce the problem:
https://github.com/poppinlr/client.git
https://github.com/poppinlr/gateway.git
https://github.com/poppinlr/serviceManagement.git
I can get response from http://localhost:8082/client/hello
as I said use the default service id
but the java config doesn't work as below
response is 404 as http://localhost:8082/clientc/hello
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("um_route", r -> r
.path("/clinetc/**")
.uri("lb://clinet/")
)
.build();
}
your route has spelling errors clinet vs client and clinetc vs clientc.
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("um_route", r -> r
.path("/clientc/**")
.filters(f -> f.stripPrefix(1))
.uri("lb://client/")
)
.build();
}
.filters(f -> f.stripPrefix(1))
Sorry for spelling mistake,
I think .filters(f -> f.stripPrefix(1)) help to solve the problem, thanks!
Most helpful comment
Sorry for spelling mistake,
I think
.filters(f -> f.stripPrefix(1))help to solve the problem, thanks!