一、pom增加

        <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

二、使用

启动类无需任何设置,设置配置文件

spring:
application:
name: gateway-service
cloud:
gateway:
# discovery: #方式一、是否与服务发现组件进行结合,通过 serviceId(必须设置成大写) 转发到具体的服务实例。默认为false,设为true便开启通过服务中心的自动根据 serviceId 创建路由的功能。
# locator: #路由访问方式:http://Gateway_HOST:Gateway_PORT/大写的serviceId/**,其中微服务应用名默认大写访问。
# enabled: true
# routes: #方式二 使用lb负载均衡加载
# - id: USERSERVICE
# uri: lb://USER-SERVICE:8762
# predicates:
# - Path=/userapi/**
# filters:
# - StripPrefix=1
routes: #方式三 直接使用 域名地址
- id: USERSERVICE
uri: http://localhost:8762
predicates:
- Path=/userapi/**
filters:
- StripPrefix=1

参考代码:https://github.com/bjlhx15/spring-cloud-base/tree/master/spring-cloud-sleuth-study

011-spring cloud gateway-使用的更多相关文章

  1. springcloud3(五) spring cloud gateway动态路由的四类实现方式

    写这篇博客主要是为了汇总下动态路由的多种实现方式,没有好坏之分,任何的方案都是依赖业务场景需求的,现在网上实现方式主要有: 基于Nacos, 基于数据库(PosgreSQL/Redis), 基于Mem ...

  2. 从0开始构建你的api网关--Spring Cloud Gateway网关实战及原理解析

    API 网关 API 网关出现的原因是微服务架构的出现,不同的微服务一般会有不同的网络地址,而外部客户端可能需要调用多个服务的接口才能完成一个业务需求,如果让客户端直接与各个微服务通信,会有以下的问题 ...

  3. Spring cloud gateway

    ==================================为什么需要API gateway?==================================企业后台微服务互联互通, 因为 ...

  4. Spring Cloud Gateway Ribbon 自定义负载均衡

    在微服务开发中,使用Spring Cloud Gateway做为服务的网关,网关后面启动N个业务服务.但是有这样一个需求,同一个用户的操作,有时候需要保证顺序性,如果使用默认负载均衡策略,同一个用户的 ...

  5. 简单尝试Spring Cloud Gateway

    简单尝试Spring Cloud Gateway 简介 Spring Cloud Gateway是一个API网关,它是用于代替Zuul而出现的.Spring Cloud Gateway构建于Sprin ...

  6. spring cloud gateway的stripPrefix配置

    序 本文主要研究下spring cloud gateway的stripPrefix配置 使用zuul的配置 zuul: routes: demo: sensitiveHeaders: Access-C ...

  7. Spring Cloud Gateway中异常处理

    最近我们的项目在考虑使用Gateway,考虑使用Spring Cloud Gateway,发现网关的异常处理和spring boot 单体应用异常处理还是有很大区别的.让我们来回顾一下异常. 关于异常 ...

  8. api网关揭秘--spring cloud gateway源码解析

    要想了解spring cloud gateway的源码,要熟悉spring webflux,我的上篇文章介绍了spring webflux. 1.gateway 和zuul对比 I am the au ...

  9. SpringCloud无废话入门05:Spring Cloud Gateway路由、filter、熔断

    1.什么是路由网关 截至目前为止的例子中,我们创建了一个service,叫做:HelloService,然后我们把它部署到了两台服务器(即提供了两个provider),然后我们又使用ribbon将其做 ...

  10. spring cloud gateway - RequestRateLimiter

    1. Official website 5.7 RequestRateLimiter GatewayFilter Factory The RequestRateLimiter GatewayFilte ...

随机推荐

  1. JS - url相关

    今天在找获取当前网址除去参数的js方式,结果自己会的竟然只有window.location.href 查到的一篇博文: http://www.cnblogs.com/weiyuxinghuacun/a ...

  2. Python学习(22):模块

    转自 http://www.cnblogs.com/BeginMan/p/3183656.html 一.模块基础 1.模块 自我包含,且有组织的代码片段就是模块 模块是Pyhon最高级别的程序组织单元 ...

  3. css方法 - 移动端h5在iphonex的适配

    @media only screen and (device-width:375px) and (device-height:812px) and (-webkit-device-pixel-rati ...

  4. EGit 在使用时出现 git-upload-pack not found 的错误

    在 Ubuntu 上使用Eclipse 的插件 EGit 从 GitHub 上下载资源时出现 git-upload-pack not found 的错误,如图 (另,EGit 在 Windows 上的 ...

  5. JUnit —— TestSuite 的使用

    首先说一下,suite ,中文是 一套,一组 的意思. 那么,TestSuite,顾名思义,就是用来运行一组测试的. 如何使用呢 ? 假设有个这样的测试类 StudentDAOTest ,代码如下: ...

  6. CacheDependency 的使用方法

    //创建缓存依赖项 CacheDependency dep = new CacheDependency(fileName); //创建缓存 HttpContext.Current.Cache.Inse ...

  7. Android开发进阶从小工到专家之性能优化

  8. javascript取querystring,存储为hash

    function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location ...

  9. 生产环境的gitlab大版本升级思路(从7.x升级到8.x)

    之前在生产环境部署的gitlab是7.x版本的,提供给公司内部的员工来使用,大概有350个用户左右,gitlab从8.x版本之后内置了CI和CD的集成,所以就考虑到升级版本的问题 通过参考和总结git ...

  10. 利用开源架构ELK构建分布式日志系统

    问题导读 1.ELK产生的背景?2.ELK的基本组成模块以及各个模块的作用?3.ELK的使用总计有哪些? 背景 日志,对每个系统来说,都是很重要,又很容易被忽视的部分.日志里记录了程序执行的关键信息, ...