本案例,將/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