引入依赖
<!-- gateway -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
路由配置
server:port: 8088
spring:application:name: api-gatewaycloud:gateway:routes:- id: order_route # 路由唯一标识uri: http://localhost:8020 # 需要转发的地址# 断言规则 用于路由规则的匹配predicates:- Path=/order-serv/**# http://localhost:8088/order-serv/order/add => http://localhost:8020/order-serv/order/addfilters:- StripPrefix=1 # 转发去掉第一层路径# http://localhost:8020/order-serv/order/add => http://localhost:8020/order/add
访问效果