gateway是Hoxton.SR1版本的spring-cloud-dependencies引入的,spring-cloud-gateway-core版本是2.2.1.RELEASE,这个版本的自动路由有bug,配置了discovery.locator.enabled=true也不会自动生成路由。
有人在github提了issue:https://github.com/spring-cloud/spring-cloud-commons/issues/842
这个需要换版本或者手工配置凑合用,我这边把Hoxton.SR1换成Hoxton.SR12就可以了,我是自己用的。不方便整体升级的话可以试试只升级spring-cloud-gateway-core。
升级jar包是解决路由404的问题
如果是报503的错误,要加下loadbalancer
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>