本案例,将/helloworld-app/**的请求转发到helloworld微服务的/**路径(既如lb://helloworld/**)
配置如下(见spring.cloud.gateway.routes配置):
spring:application:name: SpringCloudGatewayDemocloud:nacos:discovery:server-addr: localhost:8848namespace: b62b1132-d8c6-4740-b745-75bcfb4f66a5cluster-name: GDgateway:discovery:locator:# 让gateway通过服务发现组件找到其他的微服务enabled: trueroutes:- id: helloworld_routeuri: lb://helloworldpredicates:- Path=/helloworld-app/**filters:- RewritePath= /helloworld-app/(?<segment>.*), /${segment}
server:port: 8099
management:endpoints:web:exposure:include: '*'endpoint:health:show-details: always