一、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. [OpenGL]用OpenGL制作动画

    //在窗口内绘制一个移动的矩形 /*我们通常还可以用OpenGL程序创建动画效果,这里我们利用前面的例子,绘制正方形,并使这个正方形在窗口的边框反弹.这里需要创建一个循环,在每次调用显示回调函数之前改 ...

  2. ab压测工具

    在学习ab工具之前,我们需了解几个关于压力测试的概念 吞吐率(Requests per second)概念:服务器并发处理能力的量化描述,单位是reqs/s,指的是某个并发用户数下单位时间内处理的请求 ...

  3. nginx中实现把所有http的请求都重定向到https

    在网站启用https之后,我们可能会有一个需求,就是将所有的http的请求自动地重定向到https, 如果前端是使用的nginx来实现的https,我们可以这样配置nginx的301重定向: serv ...

  4. facebook login issue

    If enable the facebook account in settings, when change account can't open the session. -(void)fbRes ...

  5. SVN服务端安装

    1 首先安装SVN和Subversion. 安装文件可自行百度. 2 在服务端创建版本库. 我的安装目录是c:\Program Files(x86)\Subversion. 安装完成后在安装目录下sh ...

  6. DependencyProperty属性介绍

    1  DependencyProperty从属属性 1.     从属属性要定义为静态.为了在外部可以绑定,最好定义为Public 2.     从属属性实际上是取代了正常属性的存值变量 3.     ...

  7. Memcached下载安装、NET对Memcached进行CRUD操作(2)

    Memcached概念.作用.运行原理.特性.不足简单梳理(1) Memcached下载安装.NET对Memcached进行CRUD操作(2) Memcached存Session数据.访问安全性.使用 ...

  8. [APP] Android 开发笔记 004-Android常用基本控件使用说明

    TextView 文本框 EditText控件 Button 与 ImageButton ImageView RadioButton CheckBox复选框 TextView 文本框 ,用于显示文本的 ...

  9. MAC SVN 基本设置 终端命令

    extends:http://www.cnblogs.com/heiniuhaha/archive/2012/07/31/2616493.html 安装XCode后Mac OS X 系统已经内置了sv ...

  10. layerui如何隐藏按钮?

    https://www.layui.com/doc/modules/layer.html#btn 建议把 btn: ['取消'],btnAlign: 'c',yes: function (index) ...