我想使用带有eureka的spring cloud网关进行定位服务 我的路线配置:
spring:
cloud:
gateway:
discovery.locator.enabled: true
routes:
- id: dicts
uri: lb://neoflex-dict
predicates:
- Path=/dicts/**
- id: oauth
uri: lb://auth_server
predicates:
- Path=/oauth/**
- id: catalog
uri: lb://catalog
predicates:
- Path=/catalog/**
- id: users
uri: lb://auth_server
predicates:
- Path=/users/**
- id: neoflex-dict-front
uri: lb://neoflex-dict-front
predicates:
- Path=/dicts_front/**
我添加到主类
@Bean
public DiscoveryClientRouteDefinitionLocator clientRouteDefinitionLocator(DiscoveryClient discoveryClient) {
return new DiscoveryClientRouteDefinitionLocator(discoveryClient);
}
我收到错误消息
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.0.M9.jar:2.0.0.M9]
中的问题
final ServiceInstance instance = loadBalancer.choose(url.getHost());
我无法理解为什么url = http://localhost:8600/oauth/token