spring:
application:
name: api-gateway
cloud:
gateway:
routes:
# 路由id,可以随意写
- id: user-service-route
# 代理的服务地址
uri: http://127.0.0.1:9091
#uri: lb://user-service
# 路由断言,可以配置映射路径
predicates:
- Path=/user/**
上文中的uri参数HTTP不能大写。大写没有数据返回。小写才行。用lb也行。

本文介绍了SpringCloudGateway的配置,包括应用名(api-gateway),路由设置(user-service-route)以及URI的使用。关键点在于URI必须使用小写(http://127.0.0.1:9091)或lb负载均衡方式(lb://user-service)来正确路由到服务,并通过Path断言匹配/user/**的路径。

被折叠的 条评论
为什么被折叠?



