初探Spring Cloud Gateway实战

目录
  • 关于Spring Cloud Gateway
  • 版本信息
  • 经典配置中的核心概念
  • 启动nacos-2.0.3
  • 源码下载
  • 《Spring Cloud Gateway实战》系列的父工程
  • 创建名为common的子工程,存放共用的常量和数据结构
  • 创建web应用,作为服务提供方
  • 开发一个简单的demo,完成spring-cloud-gateway的初体验
  • 总结

关于Spring Cloud Gateway

  • 这是一个基于Spring技术栈构建的API网关,涉及到:Spring5、Spring Boot 2、Reactor等,目标是为项目提供简单高效的API路由,以及强大的扩展能力:安全、监控、弹性计算等
  • 官方架构图如下,可见请求到来后,由Handler Mapping决定请求对应的真实目标,然后交给Web Handler,由一系列过滤器(filter)执行链式处理,从红色箭头和注释可以发现,请求前后都有过滤器在运行:

版本信息

  • 《Spring Cloud Gateway实战》系列涉及的软件和库版本信息如下:
  • 本篇实战涉及到的主要版本情况如下:

1.JDK:1.8.0_291

2.IDEA:2021.1.3 (Ultimate Edition)

3.maven:3.8.1

4.操作系统:win10 64位

5.springboot:2.4.2

6.spring-cloud:2020.0.1

7.spring-cloud-alibaba:2021.1

经典配置中的核心概念

  • 先通过一个典型的简化版配置来了解几个核心概念,假设Spring Cloud Gateway应用正在运行,监听8080端口,一旦有远程请求来到8080端口,下面的配置就会生效了,三个核心概念,以及每个配置的作用,请参考中文注释:
spring:
  cloud:
    gateway:
      # 核心概念1:路由,一个路由代表一个处理逻辑,
      # 该逻辑里面包含三个元素:匹配条件(是否该此路由处理)、真实处理地址、过滤器
      routes:
        # id要确保唯一性
      - id: add_request_header_route
      	# 真实处理地址,请求一旦确定是当前路由处理,就会转发到这个地址去
        uri: https://example.org
        # 核心概念2:谓语或者断言,作用是判断请求是否由当前路由处理
        predicates:
          # 这是断言的一种,检查请求的Cookie中mycookie的值是否等于mycookievalue
        - Cookie=mycookie,mycookievalue
        # 核心概念3:过滤器,请求前和请求后都可以有过滤器处理请求响应数据
        filters:
          # 这个过滤器的作用是在请求header中添加一个键值对,值等于"aaabbbccc"
        - AddRequestHeader=X-Request-Red, aaabbbccc
  • 上述配置信息中的predicates是简化版配置,和完整配置对比效果如下,简单的说就是把一行拆成了三项:name、args.name、args.regexp

  • 理论知识点到为止,咱们还是尽快动手吧

启动nacos-2.0.3

  • 整个《pring Cloud Gateway实战》系列,我们会涉及到多个服务,这就不可避免的会用到注册中心和配置中心,这里我选择了nacos,它可以很好地承担注册中心和配置中心的角色,接下来介绍如何部署和启动nacos
  • 下载nacos,地址是:https://github.com/alibaba/nacos/releases/download/2.0.3/nacos-server-2.0.3.zip
  • 解压后进入nacos\bin目录,执行以下命令启动nacos:

startup.cmd -m standalone

如果您的电脑是mac或者linux,请执行以下命令启动nacos:

sh startup.sh -m standalone

源码下载

本篇实战中的完整源码可在GitHub下载到,地址和链接信息如下表所示(https://github.com/zq2599/blog_demos):

名称 链接 备注
项目主页 https://github.com/zq2599/blog_demos 该项目在GitHub上的主页
git仓库地址(https) https://github.com/zq2599/blog_demos.git 该项目源码的仓库地址,https协议
git仓库地址(ssh) git@github.com:zq2599/blog_demos.git 该项目源码的仓库地址,ssh协议

这个git项目中有多个文件夹,本篇的源码在spring-cloud-tutorials文件夹下,如下图红框所示:

《Spring Cloud Gateway实战》系列的父工程

新建名为spring-cloud-tutorials的maven工程,这就是《Spring Cloud Gateway实战》系列所有源码的父工程就,pom.xml内容如下,可见这里将springboot、spring-cloud、spring-cloud-alibaba库的版本号都已经确定,今后子工程就无需关注依赖库的版本号了:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <modules>
        <module>hello-gateway</module>
        <module>provider-hello</module>
        <module>common</module>
    </modules>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.2</version>
        <relativePath/>
    </parent>
    <groupId>com.bolingcavalry</groupId>
    <artifactId>spring-cloud-tutorials</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <java.version>1.8</java.version>
        <spring-cloud.version>2020.0.1</spring-cloud.version>
        <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
    </properties>
    <packaging>pom</packaging>
    <description>Demo project for Spring Cloud </description>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>okhttp</artifactId>
                <version>3.14.9</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.1.7</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.16.16</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

创建名为common的子工程,存放共用的常量和数据结构

  • 现在创建名为common的子工程,整个《Spring Cloud Gateway实战》系列涉及的常量和数据结构都放在这个子工程中,方便其他工程使用
  • 新增常量Constants.java:
package com.bolingcavalry.common;
public interface Constants {
    String HELLO_PREFIX = "Hello World";
}

创建web应用,作为服务提供方

  • 现在创建名为provider-hello的web应用,这是个极其普通的web应用,提供几个http接口服务,咱们在尝试Spring Cloud Gateway的基本功能时,都会将请求路由到provider-hello上来
  • provider-hello是个普通的springboot应用,会在nacos进行注册,其pom.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>spring-cloud-tutorials</artifactId>
        <groupId>com.bolingcavalry</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>provider-hello</artifactId>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>com.bolingcavalry</groupId>
            <artifactId>common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--nacos:用于服务注册与发现-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- 如果父工程不是springboot,就要用以下方式使用插件,才能生成正常的jar -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.bolingcavalry.provider.ProviderApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

工程的配置文件application.yml如下,web端口是8082,还有一处要注意的是nacos服务地址:

server:
  #服务端口
  port: 8082
spring:
  application:
    name: provider-hello
  cloud:
    nacos:
      discovery:
        # nacos服务地址
        server-addr: 127.0.0.1:8848
  • 启动类ProviderApplication.java
package com.bolingcavalry.provider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
public class ProviderApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication.class, args);
    }
}
  • 普通的Controller类Hello.java,对外提供一个http服务:
package com.bolingcavalry.provider.controller;
import com.bolingcavalry.common.Constants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
@RequestMapping("/hello")
public class Hello {
    private String dateStr(){
        return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
    }
    /**
     * 返回字符串类型
     * @return
     */
    @GetMapping("/str")
    public String helloStr() {
        return Constants.HELLO_PREFIX + ", " + dateStr();
    }
}

新增测试类HelloTest.java,用于检查应用的服务是否正常:

package com.bolingcavalry.provider.controller;
import com.bolingcavalry.common.Constants;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@AutoConfigureMockMvc
@Slf4j
class HelloTest {
    @Autowired
    private MockMvc mvc;
    @Test
    void hello() throws Exception {
        String responseString = mvc.perform(MockMvcRequestBuilders.get("/hello/str").accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(content().string(containsString(Constants.HELLO_PREFIX)))
                .andDo(print())
                .andReturn()
                .getResponse()
                .getContentAsString();
        log.info("response in junit test :\n" + responseString);
    }
}

执行单元测试(此时nacos是否启动无所谓,只是不启动的话控制台会有一些错误信息,但是没有影响),如下,测试通过表示服务是正常的:

开发一个简单的demo,完成spring-cloud-gateway的初体验

  • 前面做了那么多准备,接下来咱们会投入到Spring Cloud Gateway的开发中,先写个简单的demo快速体验一下
  • 新增名为hello-gateway的子工程,pom.xml如下,重点是依赖了spring-cloud-starter-gateway库,还有一处要重点小心的:测试库用的是reactor-test和spring-boot-starter-test,这和之前的单元测试很不一样,用的是webflux:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>spring-cloud-tutorials</artifactId>
        <groupId>com.bolingcavalry</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>hello-gateway</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.bolingcavalry</groupId>
            <artifactId>common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
  • 下面是重点,Spring Cloud Gateway的配置文件application.yml,:
server:
  #服务端口
  port: 8081
spring:
  application:
    name: hello-gateway
  cloud:
    gateway:
      routes:
        - id: path_route
          # 匹配成功后,会被转发到8082端口,至于端口后面的path,会直接使用原始请求的
          # 例如http://127.0.0.1:8081/hello/str,会被转发到http://127.0.0.1:8082/hello/str
          uri: http://127.0.0.1:8082
          predicates:
            # 根据请求路径中带有"/hello/",就算匹配成功
          - Path=/hello/**

如果要转发到其他域名下,需要创建配置类解决跨域问题:

package com.bolingcavalry.hellogateway.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
import org.springframework.web.util.pattern.PathPatternParser;
@Configuration
public class CorsConfig {
    @Bean
    public CorsWebFilter corsFilter() {
        CorsConfiguration config = new CorsConfiguration();
        config.addAllowedMethod("*");
        config.addAllowedOrigin("*");
        config.addAllowedHeader("*");
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
        source.registerCorsConfiguration("/**", config);
        return new CorsWebFilter(source);
    }
}
  • 启动类:
package com.bolingcavalry.hellogateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HelloGatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(HelloGatewayApplication.class,args);
    }
}
  • 最后是单元测试类,请注意,由于Spring Cloud Gateway使用了webflux技术栈,因此不能用常见的MockMvc来模拟请求,几个注解也值得注意,另外也要注意WebTestClient的expectStatus、expectBody等API的用法:
package com.bolingcavalry.hellogateway;
import com.bolingcavalry.common.Constants;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.reactive.server.WebTestClient;
import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest
@ExtendWith(SpringExtension.class)
@AutoConfigureWebTestClient
public class HelloTest {
    @Autowired
    private WebTestClient webClient;
    @Test
    void testHelloPredicates() {
        webClient.get()
                .uri("/hello/str")
                .accept(MediaType.APPLICATION_JSON)
                .exchange()
                // 验证状态
                .expectStatus().isOk()
                // 验证结果,注意结果是字符串格式
                .expectBody(String.class).consumeWith(result  -> assertTrue(result.getResponseBody().contains(Constants.HELLO_PREFIX)));
    }
}

请确保provider-hello应用已经启动,再运行上面创建的HelloTest.java,得到结果如下,测试通过,证明hello-gateway的功能符合预期,成功的将请求转发到provider-hello应用,并且成功收到响应:

至此,《Spring Cloud Gateway实战》系列的准备工作已经完成,而且开发了一个简单的应用体验最基本的Spring Cloud Gateway功能,接下来的文章,咱们一起实战更多基本功能。

总结

本篇文章就到这里了,希望能给你带来帮助,也希望您能够多多关注我们的更多内容!

(0)

相关推荐

  • Nacos+Spring Cloud Gateway动态路由配置实现步骤

    目录 前言 一.Nacos环境准备 1.启动Nacos配置中心并创建路由配置 2.连接Nacos配置中心 二.项目构建 1.项目结构 2.编写测试代码 三.测试动态网关配置 1.启动服务,观察注册中心 2.访问网关,观察服务日志 四.总结 前言 Nacos最近项目一直在使用,其简单灵活,支持更细粒度的命令空间,分组等为麻烦复杂的环境切换提供了方便:同时也很好支持动态路由的配置,只需要简单的几步即可.在国产的注册中心.配置中心中比较突出,容易上手,本文通过gateway.nacos-consume

  • Nginx+SpringCloud Gateway搭建项目访问环境

    目录 安装Nginx 准备SpringBoot应用 添加网关 现如今的项目开发基本都是微服务方式,导致一个系统中会有很多的服务,每个模块都对应着不同的端口,为了方便访问,通常会让某个服务绑定一个域名,比如商品服务:product.xxx.com:订单服务:order.xxx.com,此时可以使用Nginx来搭建一个域名访问环境,基于前后端分离开发的项目经常会遇到跨域问题,使用Nginx也能轻松解决. 安装Nginx 首先拉取nginx的镜像: docker pull nginx:1.10 然后随

  • Spring Cloud Gateway自定义异常处理Exception Handler

    版本: Spring Cloud 2020.0.3 常见的方法有 实现自己的 DefaultErrorWebExceptionHandler 或 仅实现ErrorAttributes. 方法1: ErrorWebExceptionHandler (仅供示意) 自定义一个 GlobalErrorAttributes: @Component public class GlobalErrorAttributes extends DefaultErrorAttributes{ @Override pub

  • SpringCloud gateway request的body验证或修改方式

    SpringCloud gateway request的body验证或修改 后续版本新增了以下过滤器 org.springframework.cloud.gateway.filter.headers.RemoveHopByHopHeadersFilter 默认会把以下头部移除(暂不了解这做法的目的) - connection - keep-alive - te - transfer-encoding - trailer - proxy-authorization - proxy-authenti

  • Java之Springcloud Gateway内置路由案例讲解

    Spring Cloud Gateway路由匹配是Spring WebFlux基础功能的一部分,在Spring Cloud Gateway中内置了很多路由断言工厂类.不同的断言工厂类针对HTTP请求的不同属性.多个断言工厂类可以使用逻辑"and"进行组合使用. 4.1 After Route Predicate Factory        这个Predicate工厂的实现类是AfterRoutePredicateFactory,使用一个时间参数,如果当前请求的时间在配置的赶时间之后,

  • 初探Spring Cloud Gateway实战

    目录 关于Spring Cloud Gateway 版本信息 经典配置中的核心概念 启动nacos-2.0.3 源码下载 <Spring Cloud Gateway实战>系列的父工程 创建名为common的子工程,存放共用的常量和数据结构 创建web应用,作为服务提供方 开发一个简单的demo,完成spring-cloud-gateway的初体验 总结 关于Spring Cloud Gateway 这是一个基于Spring技术栈构建的API网关,涉及到:Spring5.Spring Boot

  • 详解Spring Cloud Gateway修改请求和响应body的内容

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 作为<Spring Cloud Gateway实战>系列的第九篇,咱们聊聊如何用Spring Cloud Gateway修改原始请求和响应内容,以及修改过程中遇到的问题 首先是修改请求body,如下图,浏览器是请求发起方,真实参数只有user-id,经过网关时被塞入字段user-name,于是,后台服务收到的请求就带有user-name字段

  • Spring Cloud Gateway编码实现任意地址跳转的示例

    目录 本篇概览 一般路由规则 特殊规则 设计 源码下载 编码 配置 开发和启动后台服务,模拟生产和测试环境 验证 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 作为<Spring Cloud Gateway实战>系列的第十四篇,本文会继续发掘Spring Cloud Gateway的潜力,通过编码体验操控网关的乐趣,开发出一个实用的功能:让Spring Cloud Gateway应用在收到请求后,可以按照业务的

  • spring cloud gateway集成hystrix实战篇

    spring cloud gateway集成hystrix 本文主要研究一下spring cloud gateway如何集成hystrix maven <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependency> 添加spring-

  • Spring Cloud Gateway 默认的filter功能和执行顺序介绍

    目录 Spring Cloud Gateway 默认的filter功能和执行顺序 有效性 调试方法 filters(按执行顺序) spring cloud gateway之filter实战 1.filter的作用和生命周期 2.AddRequestHeader GatewayFilter Factory Spring Cloud Gateway 默认的filter功能和执行顺序 有效性 Spring Cloud Gateway 2.0.0.RELEASE 调试方法 新建一个GlobalFilte

  • 聊聊Spring Cloud Gateway过滤器精确控制异常返回问题

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览在<Spring Cloud Gateway修改请求和响应body的内容>一文中,咱们通过filter成功修改请求body的内容,当时留下个问题:在filter中如果发生异常(例如请求参数不合法),抛出异常信息的时候,调用方收到的返回码和body都是Spring Cloud Gateway框架处理后的,调用方无法根据这些内容知道真正的错误原因

  • Spring Cloud Gateway整合sentinel 实现流控熔断的问题

    目录 一.什么是网关限流: 二.gateway 整合 sentinel 实现网关限流: 三.sentinel 网关流控规则的介绍: 3.1.网关流控规则: 3.2.API 分组管理: 四.sentinel 网关流控实现的原理: 五.网关限流了,服务就安全了吗? 六.自定义流控异常消息: 一.什么是网关限流: 在微服务架构中,网关层可以屏蔽外部服务直接对内部服务进行调用,对内部服务起到隔离保护的作用,网关限流,顾名思义,就是通过网关层对服务进行限流,从而达到保护后端服务的作用. Sentinel

  • 阿里Sentinel支持Spring Cloud Gateway的实现

    1. 前言 4月25号,Sentinel 1.6.0 正式发布,带来 Spring Cloud Gateway 支持.控制台登录功能.改进的热点限流和注解 fallback 等多项新特性,该出手时就出手,紧跟时代潮流,昨天刚发布,今天我就要给大家分享下如何使用! 2. 介绍(本段来自Sentinel文档) Sentinel 1.6.0 引入了 Sentinel API Gateway Adapter Common 模块,此模块中包含网关限流的规则和自定义 API 的实体和管理逻辑: Gatewa

  • Spring Cloud Gateway使用Token验证详解

    引入依赖 <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <ty

  • Spring Cloud GateWay 路由转发规则介绍详解

    Spring在因Netflix开源流产事件后,在不断的更换Netflix相关的组件,比如:Eureka.Zuul.Feign.Ribbon等,Zuul的替代产品就是SpringCloud Gateway,这是Spring团队研发的网关组件,可以实现限流.安全认证.支持长连接等新特性. Spring Cloud Gateway Spring Cloud Gateway是SpringCloud的全新子项目,该项目基于Spring5.x.SpringBoot2.x技术版本进行编写,意在提供简单方便.可

随机推荐