GateWay⽀持⾃动从注册中⼼中获取服务列表并访问,即所谓的动态路由
spring:
application:
name: cloud-gateway
cloud:
gateway:
routes:
- id: eureka-client
uri: lb://eureka-client
predicates:
- Path=/client/**
filters:
- StripPrefix=1
注意:动态路由设置时,uri以 lb://开头(lb代表从注册中⼼获取服务),后⾯是需要转发到的服务名称,上面的代码使用了动态路由,表示程序在调用的时候自动会在eureka注册中心中找到服务实例名为eureka-client进行调用