Spring Cloud 学习 - Gateway新一代网关

Spring Cloud Gateway是基于Spring 5.0+Spring Boot 2.x和Project Reactor构建的高性能网关,旨在替代Zuul。本文介绍了如何引入依赖、设置服务发现、编写配置以及自定义全局过滤器,并提供了简单的测试。通过Spring Cloud Gateway,可以方便地对微服务架构进行统一的API路由管理。
摘要由CSDN通过智能技术生成

Spring Cloud Gateway 新一代网关

Spring Cloud Gateway 是Spring Cloud的一个全新项目,基于Spring 5.0 + Spring Boot 2.x和Project Reactor等技术开发的网关,旨在为微服务架构提供一种有效的统一的API路由管理方式。

Spring Cloud Gateway作为Spring Cloud生态系统中的网关组件,目标是替代Zuul。由于Zuul2.x的多次跳票,为了提升网关的性能,Spring Cloud官方基于Spring WebFlux开发了非阻塞的网关组件Gateway,WebFlux框架底层使用了高性能的Reactor模式的非阻塞通信框架Netty。

引入依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

因为要从注册中心对服务实例进行动态路由,这里加入了eureka-client的依赖,把gateway注册到eureka中。

服务发现

@SpringBootApplication
@EnableDiscoveryClient
public 
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值