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. IDEA快捷建使用

    因为以前使用的IDE工具是Eclipse,所以在公司中都是用IDEA的情况下,换成了IDEA,感觉是好用了很多. 其他快捷键: Ctrl+Shift + Enter,语句完成 “!”,否定完成,输入表 ...

  2. vim命令:编辑模式和命令模式

      vim:编辑模式 从一般模式进入编辑模式,只需你按一个键即可(i,I,a,A,o,O,r,R).当进入编辑模式时,会在屏幕的最下一行出现“INSERT或REPLACE”的字样.从编辑模式回到一般模 ...

  3. ajax属性详解

    https://blog.csdn.net/mooncom/article/details/52402836 资料库: $.ajaxSetup()方法为将来的ajax请求设置默认值. http://w ...

  4. Python基础:第一个Python程序(2)

    1.Python Shell 1.1 Windows命令 (1)[开始]|[运行],输入cmd回车,进入Windows命令界面. (2)输入python,回车,进入Python Shell. 1.2 ...

  5. DNS 地址

    腾讯DNS:119.29.29.29百度DNS:  180.76.76.76  阿里DNS:223.5.5.5 223.6.6.6 成都电信: 61.139.2.69

  6. Linux-Jenkins安装部署

    Jenkins 安装及插件安装 Jenkins简介: Jenkins只是一个平台,真正运作的都是插件.这就是jenkins流行的原因,因为jenkins什么插件都有 Hudson是Jenkins的前身 ...

  7. python 向量化

    study from : https://www.jianshu.com/p/ad8933dd6407

  8. SQL2012数据库还原失败System.Data.SqlClient.SqlError: 无法执行 BACKUP LOG,因为当前没有数据库备份

    在一次数据库还原的操作过程中遇到如上错误,去百度了下找到了对应的解决方法 第一个: 在还原完整备份时候,在回复状态状态哪里选择 restore with norecovery ,尾日志部分可选可不选, ...

  9. python-tqdm进度条

    通过tqdm库可以打造自己的进度条使用 1. pip安装 pip install tqdm --trusted-host pypi.douban.com 2.使用 from time import s ...

  10. 【1】MySQL大数据量分页查询方法及其优化

    ---方法1: 直接使用数据库提供的SQL语句---语句样式: MySQL中,可用如下方法: SELECT * FROM 表名称 LIMIT M,N---适应场景: 适用于数据量较少的情况(元组百/千 ...