搭建SpringCloud Gateway

创建microservicecloud-springcloud-gateway-9528工程

pom文件 依赖:

 <dependencies>
<!-- 将微服务provider侧注册进eureka -->
<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>
<!-- swagger-spring-boot -->
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.7.0.RELEASE</version>
</dependency>
<!--api接口-->
<dependency>
<groupId>com.yehui</groupId>
<artifactId>microservicecloud-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>

yml文件

server:
port: 9528
spring:
application:
name: springcloudgetway
cloud:
gateway:
discovery:
locator:
enabled: true
lowerCaseServiceId: true
routes:
#id标签配置的是router的id,每个router都需要一个唯一的id
- id: dept_client
#uri配置的是将请求路由到哪里,
uri: lb://microservicecloud-dept
predicates:
- Path=/dept_client/client/** #如果请求地址满足/microservicecloud-dept/**,则转发到microservicecloud-dept服务
filters:
- StripPrefix=2 eureka:
client: #客户端注册进eureka服务列表内
service-url:
defaultZone: http://localhost:7002/eureka/,http://localhost:7003/eureka/,http://localhost:7001/eureka/
instance:
prefer-ip-address: true

启动类

@SpringBootApplication
public class SpringCloudGateWayApp {
public static void main(String[] args) {
SpringApplication.run(SpringCloudGateWayApp.class);
}
}

启动服务测试;

访问:http://localhost:9528/dept_client/client/dept/findAll

SpringCloud Gateway(八)的更多相关文章

  1. 微服务实战系列(八)-网关springcloud gateway自定义规则

    1. 场景描述 先说明下项目中使用的网关是:springcloud gateway, 因需要给各个网关服务系统提供自定义配置路由规则,实时生效,不用重启网关(重启风险大),目前已实现:动态加载自定义路 ...

  2. SpringCloud Gateway 测试问题解决

    本文针对于测试环境SpringCloud Gateway问题解决. 1.背景介绍 本文遇到的问题都是在测试环境真正遇到的问题,不一定试用于所有人,仅做一次记录,便于遇到同样问题的干掉这些问题. 使用版 ...

  3. SpringCloud Gateway入门

    本文是介绍一下SpringCloud Gateway简单路由转发使用. SpringCloud Gateway简介 SpringCloud是基于Spring Framework 5,Project R ...

  4. 使用springcloud gateway搭建网关(分流,限流,熔断)

    Spring Cloud Gateway Spring Cloud Gateway 是 Spring Cloud 的一个全新项目,该项目是基于 Spring 5.0,Spring Boot 2.0 和 ...

  5. 体验SpringCloud Gateway

    Spring Cloud Gateway是Spring Cloud技术栈中的网关服务,本文实战构建一个SpringCloud环境,并开发一个SpringCloud Gateway应用,快速体验网关服务 ...

  6. spring-cloud-kubernetes与SpringCloud Gateway

    本文是<spring-cloud-kubernetes实战系列>的第五篇,主要内容是在kubernetes上部署一个SpringCloud Gateway应用,该应用使用了spring-c ...

  7. SpringCloud gateway (史上最全)

    疯狂创客圈 Java 分布式聊天室[ 亿级流量]实战系列之 -25[ 博客园 总入口 ] 前言 ### 前言 疯狂创客圈(笔者尼恩创建的高并发研习社群)Springcloud 高并发系列文章,将为大家 ...

  8. springcloud gateway nullpointerexception (NettyRoutingFilter)

    最近在做一个下载功能时,发现直接调用服务是可以下载的,但是通过gateway路由下载会报NPE异常,具体如下 java.lang.NullPointerException: null at java. ...

  9. springcloud gateway 项目打包部署运行

    新建一个springboot项目然后做了一个小demo跳转到baidu pom <?xml version="1.0" encoding="UTF-8"? ...

随机推荐

  1. [洛谷P4568][JLOI2011]飞行路线

    题目大意:最短路,可以有$k$条边无费用 题解:分层图最短路,建成$k$层,层与层之间的边费用为$0$ 卡点:空间计算出错,建边写错 C++ Code: #include <cstdio> ...

  2. [洛谷P2602][ZJOI2010]数字计数

    题目大意:求区间$[l,r]$中数字$0\sim9$出现个数 题解:数位$DP$ 卡点:无 C++ Code: #include <cstdio> #include <iostrea ...

  3. STL map、set中key为结构体的用法

    下面是map定义的结构: // TEMPLATE CLASS map template<class _Kty, class _Ty, class _Pr = less<_Kty>, ...

  4. [Leetcode] rotate image 旋转图片

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  5. BZOJ day2

    十六题...(好难啊) 1051105910881191119214321876195119682242243824562463276128184720

  6. java Collections.sort()实现List排序的默认方法和自定义方法【转】

    1.java提供的默认list排序方法 主要代码: List<String> list = new ArrayList();list.add("刘媛媛"); list. ...

  7. JAVA int自动装箱

    int 转 Integer: Integer int127_1 = 127; Integer int127_2 = 127; System.out.println("int127_1 == ...

  8. 设置查看java的源程序

    1.点 “window”-> "Preferences" -> "Java" -> "Installed JRES" 2. ...

  9. [bzoj1015][JSOI2008]星球大战——并查集+离线处理

    题解 给定一张图,支持删点和询问连通块个数 按操作顺序处理的话要在删除点的同时维护图的形态(即图具体的连边情况),这是几乎不可做的 我们发现,这道题可以先读入操作,把没删的点的边先连上,然后再倒序处理 ...

  10. 在SDK中使用Ubuntu仿真器

    Ubuntu仿真器是开发过程中非常有用,尤其是在没有任何Ubuntu设备时.在将仿真器附加到SDK后,你便可以在上面运行程序,安装点击数据包,等等,类似在物理设备上的操作一样. 在这里,您可以了解如何 ...