spring cloud (三) 路由 zuul
1 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId>
<artifactId>Spring-Cloud-Zuul</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>Spring-Cloud-Zuul</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
2 配置文件
zuul.routes.api-a.path=/api-a/** #路由转发地址 浏览器访问 127.0.0.1:8077//api-a/getm 会请求service-a 提供的服务
zuul.routes.api-a.serviceId=service-a #服务名称
spring.application.name=api-zuul
server.port=8077
zuul.routes.api-a.path=/api-a/**
zuul.routes.api-a.serviceId=service-a eureka.client.service-url.defaultZone=http://localhost:8080/eureka/
3 启动类
@SpringBootApplication
@EnableZuulProxy
public class SpringCloudZuulApplication { public static void main(String[] args) {
SpringApplication.run(SpringCloudZuulApplication.class, args);
}
}
4 启动服务
spring cloud (三) 路由 zuul的更多相关文章
- Spring Cloud 网关服务 zuul 三 动态路由
zuul动态路由 网关服务是流量的唯一入口.不能随便停服务.所以动态路由就显得尤为必要. 数据库动态路由基于事件刷新机制热修改zuul的路由属性. DiscoveryClientRouteLocato ...
- spring cloud 学习(6) - zuul 微服务网关
微服务架构体系中,通常一个业务系统会有很多的微服务,比如:OrderService.ProductService.UserService...,为了让调用更简单,一般会在这些服务前端再封装一层,类似下 ...
- Spring Cloud 入门 之 Zuul 篇(五)
原文地址:Spring Cloud 入门 之 Zuul 篇(五) 博客地址:http://www.extlight.com 一.前言 随着业务的扩展,微服务会不对增加,相应的其对外开放的 API 接口 ...
- spring cloud中代理服务器zuul的使用
spring cloud中代理服务器zuul的使用 主流网关: zuul kong 基于nginx的API Gateway nginx+lua 1.新建项目,选择eureka ...
- Spring Cloud 服务网关Zuul
Spring Cloud 服务网关Zuul 服务网关是分布式架构中不可缺少的组成部分,是外部网络和内部服务之间的屏障,例如权限控制之类的逻辑应该在这里实现,而不是放在每个服务单元. Spring Cl ...
- Spring Cloud Gateway VS Zuul 比较,怎么选择?
Spring Cloud Gateway 是 Spring Cloud Finchley 版推出来的新组件,用来代替服务网关:Zuul. 那 Spring Cloud Gateway 和 Zuul 都 ...
- Spring Cloud(Dalston.SR5)--Zuul 网关-路由配置
Spring Cloud 在 Zuul 的 routing 阶段实现了几个过滤器,这些过滤器决定如何进行路由工作. 简单路由(SimpleHostRoutingFilter) 该过滤器运行后,会将 H ...
- spring cloud网关通过Zuul RateLimit 限流配置
目录 引入依赖 配置信息 RateLimit源码简单分析 RateLimit详细的配置信息解读 在平常项目中为了防止一些没有token访问的API被大量无限的调用,需要对一些服务进行API限流.就好比 ...
- Spring Cloud 网关服务 zuul 二
有一点上篇文章忘了 讲述,nacos的加载优先级别最高.服务启动优先拉去配置信息.所以上一篇服务搭建我没有讲述在nacos 中心创建的配置文件 可以看到服务端口和注册中心都在配置文件中配置化 属性信息 ...
随机推荐
- Nginx 配置学习
官方文档 一.概述 Nginx的配置放在配置文件nginx.conf/etc/nginx/nginx.conf中,大概的结构如下: main # 全局配置 events { # nginx工作模式配置 ...
- 【MongoDB学习之六】MongoDB集群
环境 MongoDB 4.0 CentOS 6.5_x64 一.主从复制-Master-Slave这种模式已不再推荐使用了. 二.副本集-Replica Set(用的多)副本集其实一种互为主从的关系, ...
- Git 更新
在向远程仓库推送之前,为避免冲突,通常会先从远程仓库更新,再添加文件,再commit到staging area,最近push. 更新使用命令git pull 1 2 3 4 5 6 7 8 9 10 ...
- oracle全库查找是否有某个值
在scott用户下面,搜索含有'要找的值'的数据的表和字段穷举法: declare v_Sql ); v_count number; begin for xx in (select t.OWNER, ...
- 配置git diff和git merge使用的第三方工具
一般在运行git merge branchName后,git 如果提示了merger冲突,然后运行git mergetool.Git提示冲突后,运行git mergetool --tool-help ...
- 单点登录(SSO)解决方案介绍
一.单点登录的介绍 单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用 ...
- js中基本包装类型详情
基本包装类型 基本包装类型有Boolean,Number和string类型,每当读取一个基本类型值时,后台就会创建一个对应的基本包装类型对象. 从逻辑上,基本类型值不是对象,没有方法,但从技术上来看, ...
- golang的time包
Time对象转换为string和时间戳调用Time对象的方法 转换为string:Time.Format(输出的格式) 转换为时间戳 :Time.Unix() 两者转换为Time对象的时候调用的是ti ...
- 【数据结构】11.java源码关于TreeMap
目录 1.TreehMap的内部结构 2.TreehMap构造函数 3.元素新增策略 4.元素删除 5.元素修改和查找 6.特殊操作 7.扩容 8.总结 1.TreeMap的内部结构 首先确认一点,t ...
- CLRS10.2-4练习 - 修改链表查询方法
要求: As written, each loop iteration in the LIST-SEARCH' procedure requires two tests:one for x ≠ L.n ...