Spring Cloud  Zuul 

1.pom.xml

<!-- zuul 网关服务 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>

2.application.yml

spring:
application:
name: zuul-proxy zuul:
routes:
a:
path: /a/**
url: http://localhost:8091/
b:
path: /b/**
serviceId: hystrix-client server:
port: 8888
  • 把请求路径a代理到http://localhost:8091/ 通过url指定
  • 把请求路径b代理到hystrix-client 通过serviceId指定

Application.java

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

访问: http://localhost:8888/a/hystrix/he
Hello World!
访问: http://localhost:8888/b/hystrix/he
Hello World!

Spring Cloud 2-Zuul 网关服务(六)的更多相关文章

  1. spring cloud 通过zuul网关去请求的时候报404的几个原因。

    spring cloud 中 zuul 网关的那些坑: 1.检查你的服务是否正常启动. 2.检查你的服务是否正常注册到注册中心. 3.zuul网关的路由规则是会把你注册在注册中心的serviceId ...

  2. Spring Cloud之Zuul网关路由

    前端请求先通过nginx走到zuul网关服务,zuul负责路由转发.请求过滤等网关接入层的功能,默认和ribbon整合实现了负载均衡 比如说你有20个服务,暴露出去,你的调用方,如果要跟20个服务打交 ...

  3. Spring Cloud之Zuul网关集群

    Nginx+Zuul 一主一备 或者 轮训多个 在微服务中,所有服务请求都会统一到Zuul网关上. Nginx 配置: #user nobody; worker_processes 1; #error ...

  4. Spring Cloud系列-Zuul网关集成JWT身份验证

    前言 这两三年项目中一直在使用比较流行的spring cloud框架,也算有一定积累,打算有时间就整理一些干货与大家分享. 本次分享zuul网关集成jwt身份验证 业务背景 项目开发少不了身份认证,j ...

  5. Spring Cloud使用Zuul网关时报错

    当开启了Eureka集群后,每创建一个服务都要往这两个集群中进行注册否则访问时会产生500

  6. Spring Cloud 系列之 Gateway 服务网关(一)

    什么是 Spring Cloud Gateway Spring Cloud Gateway 作为 Spring Cloud 生态系统中的网关,目标是替代 Netflix Zuul,其不仅提供统一的路由 ...

  7. Spring Cloud 系列之 Gateway 服务网关(四)

    本篇文章为系列文章,未读第一集的同学请猛戳这里: Spring Cloud 系列之 Gateway 服务网关(一) Spring Cloud 系列之 Gateway 服务网关(二) Spring Cl ...

  8. Spring Cloud Netflix Zuul 重试会自动跳过经常超时的服务实例的简单说明和分析

    在使用E版本的Spring Cloud Netflix Zuul内置的Ribbon重试功能时,发现Ribbon有一个非常有用的特性: 如果某个服务的某个实例经常需要重试,Ribbon则会在自己维护的一 ...

  9. Spring Cloud 系列之 Gateway 服务网关(二)

    本篇文章为系列文章,未读第一集的同学请猛戳这里:Spring Cloud 系列之 Gateway 服务网关(一) 本篇文章讲解 Gateway 网关的多种路由规则.动态路由规则(配合服务发现的路由规则 ...

随机推荐

  1. 三十六、fetch

    https://developer.mozilla.org/zh-CN/docs/Web/API/Fetch_API

  2. myeclipse新建javaweb项目,并部署到tomcat

    myeclipse使用的版本: 新建web项目: File-->New-->Web Project,输入项目名称,选择J2EE规范. 完成后: JRE System Library是只要做 ...

  3. K3CLOUDJOBPROCESS每分钟重启

    1.进入服务,找到k3cloudjobprocess 2.设置每分钟重启

  4. golang异常处理

    一.使用defer+recover 错误例子: [root@localhostgo_test]#cat t1.go package main func main(){ panic(1) } [root ...

  5. AirPods 2 & Android

    AirPods 2 & Android AirBattery https://play.google.com/store/apps/details?id=friedrich.georg.air ...

  6. 原型设计的工具-----Axure RP

     原型设计的工具-----Axure RP 1.原型设计的工具 目前能用于原型设计的工具有很多,其中有七种比较好. (1)    Axure RP (2)    Mockplus (3)    Jus ...

  7. <TCP/IP原理> (三) 底层网络技术

    传输介质 局域网(LAN) 交换(Switching) 广域网(WAN) 连接设备 第三章 底层网络技术 引言 1)Interne不是一种新的网络 建立在底层网络上的网际网 底层网络——“物理网”,网 ...

  8. es定期删除数据

    es定期删除数据 1.定期删除索引 使用sentinl报警后,会产生大量如下索引,虽然不占空间,但时间久了也不好,故写个脚本定期删除 脚本如下: 1 #!/bin/bash 2 #只保留5天内的日志索 ...

  9. IIS8的SNI功能实现同一服务器多HTTPS站点

    名词解释: SNI指是一项用于改善SSL/TLS的技术,在SSLv3/TLSv1中被启用.它允许客户端在发起SSL握手请求时(具体说来,是客户端发出SSL请求中的ClientHello阶段),就提交请 ...

  10. pthread 线程立即取消的两种方法

    1.相关函数介绍 a. int pthread_cancel(pthread_t thread) 1发送终止信号给thread线程,如果成功则返回0,否则为非0值.发送成功并不意味着thread会终止 ...