spring-boot 版本 2.1.8.RELEASE
spring-cloud版本 Greenwich.SR3
spring.cloud.gateway.discovery.locator.enabled=true有设置,
把gateway配置放在nacos上调试好久,
- id: renren-fast
uri: lb://renren-fast/
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?.*),/renren-fast/$\{segment}
uri写成固定域名+端口是可以正常通过网关调用内部服务接口的,但是当配置成lb负载均衡模式,就返回空,控制台没有报错,多烦调试配置,无果后,想到了去java类里面打断点看是什么原因,点开负载均衡类,GatewayLoadBalancerClientAutoConfiguration,竟然发现
RibbonAutoConfiguration是红色的,我的天,导包也是红色的,
最后pom加入配置
org.springframework.cloudspring-cloud-starter-netflix-ribbon
后,一切正常,