锋哥原创的微服务网关Gateway视频教程:
Gateway微服务网关视频教程(无废话版)_哔哩哔哩_bilibiliGateway微服务网关视频教程(无废话版)共计17条视频,包括:1_Gateway简介、2_Gateway工作原理、3_Gateway HelloWorld快速入门等,UP主更多精彩视频,请关注UP账号。https://www.bilibili.com/video/BV1oX4y1u7ZJ/我们搞两个服务,分别是product产品服务项目,以及order订单服务项目,我们搞个小案例,搞一个网关,统一对path请求地址进行管理;
gateway依赖:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
application.yml配置:
server:port: 80servlet:context-path: /spring:application:name: gateway-servercloud:gateway:routes: # 路由规则定义- id: product-service # 路由IDuri: http://localhost:8080/ # 路由地址predicates: # 断言规则- Path=/product/**- id: order-service # 路由IDuri: http://localhost:8081/ # 路由地址predicates: # 断言规则- Path=/order/**