最近一直在搞基于springcloud的微服务开发,为了不限定微服务开发语言,服务发现决定采用consul不多说上代码

pom文件

<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>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.3.1.RELEASE</version>

<relativePath /> <!-- lookup parent from repository -->

</parent>

<groupId>com.tsx.springcloud.zuul</groupId>

<artifactId>start</artifactId>

<version>0.0.1-SNAPSHOT</version>

<packaging>jar</packaging>

<name>SpringCloudZuulStart</name>

<url>http://maven.apache.org</url>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<repositories>

<repository>

<id>dev-nexus</id>

<url>http://ob.yihecloud.com/nexus/content/groups/public/</url>

<snapshots>

<enabled>true</enabled>

<updatePolicy>always</updatePolicy>

</snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>dev-nexus</id>

<url>http://ob.yihecloud.com/nexus/content/groups/public/</url>

<snapshots>

<enabled>true</enabled>

<updatePolicy>always</updatePolicy>

</snapshots>

<releases>

<updatePolicy>never</updatePolicy>

</releases>

</pluginRepository>

</pluginRepositories>

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-dependencies</artifactId>

<version>Brixton.RELEASE</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-consul-discovery</artifactId>

<exclusions>

<exclusion>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot</artifactId>

</exclusion>

<exclusion>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-autoconfigure</artifactId>

</exclusion>

<exclusion>

<groupId>com.netflix.hystrix</groupId>

<artifactId>hystrix-core</artifactId>

</exclusion>

<!-- zuul 服务调用出错的jar包冲突 -->

<exclusion>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-netflix-core</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-feign</artifactId>

<version>1.1.7.RELEASE</version>

<exclusions>

<exclusion>

<groupId>com.netflix.hystrix</groupId>

<artifactId>hystrix-core</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-zuul</artifactId>

<version>1.1.7.RELEASE</version>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

</project>

配置

spring.cloud.consul.host=10.1.11.90

spring.cloud.consul.port=8500

spring.cloud.consul.enabled=true

spring.cloud.consul.config.enabled=false

spring.cloud.consul.discovery.enabled=true

#register is true by default, if it's true, it will register the service

spring.cloud.consul.discovery.register=true

#refer to HystrixCommandProperties

#execution.isolation.thread.interruptOnTimeout=50000

#zuul retry

#zuul.retryable=true

zuul.routes.api-c.path=/api-c/**

zuul.routes.api-c.serviceId=service-c

#zuul routes 1

zuul.routes.host.path=/host/**

zuul.routes.host.serviceId=host

#use url to instead serviceId, and it will not support hystrix and ribbon

#zuul.routes.host.url=http://172.16.4.15:8080/

#zuul routes 2

zuul.routes.virtual.path=/virtual/**

zuul.routes.virtual.serviceId=virtual

#use url to instead serviceId, and it will not support hystrix and ribbon

#zuul.routes.virtual.url=http://172.16.4.102:8080/

zuul.routes.baidu.path=/baidu/**

zuul.routes.baidu.url=http://www.baidu.com/

SpringCloud网关ZUUL集成consul的更多相关文章

  1. Api网关Kong集成Consul做服务发现及在Asp.Net Core中的使用

    写在前面   Api网关我们之前是用 .netcore写的 Ocelot的,使用后并没有完全达到我们的预期,花了些时间了解后觉得kong可能是个更合适的选择. 简单说下kong对比ocelot打动我的 ...

  2. 搭建springCloud网关zuul

    一.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...

  3. 白话SpringCloud | 第十一章:路由网关(Zuul):利用swagger2聚合API文档

    前言 通过之前的两篇文章,可以简单的搭建一个路由网关了.而我们知道,现在都奉行前后端分离开发,前后端开发的沟通成本就增加了,所以一般上我们都是通过swagger进行api文档生成的.现在由于使用了统一 ...

  4. Spring boot2X集成zuul与consul实现负载均衡和反向代理

    zuul 是netflix开源的一个API Gateway 服务器 所有从设备或网站来的请求都会经过Zuul到达后端的Netflix应用程序. 作为一个边界性质的应用程序,Zuul提供了动态路由.监控 ...

  5. 小D课堂 - 新版本微服务springcloud+Docker教程_6-02 springcloud网关组件zuul

    笔记 2.SpringCloud的网关组件zuul基本使用     简介:讲解zuul网关基本使用 1.加入依赖 2.启动类加入注解 @EnableZuulProxy         默认集成断路器 ...

  6. 玩转SpringCloud(F版本) 四.路由网关(zuul)

    本篇文章基于: 01)玩转SpringCloud 一.服务的注册与发现(Eureka) 02) 玩转SpringCloud 二.服务消费者(1)ribbon+restTemplate 03) 玩转Sp ...

  7. springcloud 实战 网关zuul使用中遇到的相关问题

    springcloud 实战  网关zuul使用中遇到的相关问题 1.网关zuul使用时,跨域问题在网关中配置pre过滤器: response.setHeader("Access-Contr ...

  8. 白话SpringCloud | 第十章:路由网关(Zuul)进阶:过滤器、异常处理

    前言 简单介绍了关于Zuul的一些简单使用以及一些路由规则的简单说明.而对于一个统一网关而言,需要处理各种各类的请求,对不同的url进行拦截,或者对调用服务的异常进行二次处理等等.今天,我们就来了解下 ...

  9. 【SpringCloud构建微服务系列】微服务网关Zuul

    一.为什么要用微服务网关 在微服务架构中,一般不同的微服务有不同的网络地址,而外部客户端(如手机APP)可能需要调用多个接口才能完成一次业务需求.例如一个电影购票的手机APP,可能会调用多个微服务的接 ...

随机推荐

  1. 安装 MySQL 后,需要调整的 10 个性能配置项

    注意:这篇博文的更新版本在这儿,MySQL 5.7 适用! 原文:Ten MySQL performance tuning settings after installation 在本文中,我们将探讨 ...

  2. Django|第一部

    Django · Django流程 · Django url · Django view · Django form ①:Django流程介绍 MTV模式 注明的MVC模式:所谓MVC就是把web应用 ...

  3. Linux进程管理详解

    何谓进程?进程,就是正在执行的一个程序或命令,每一个进程都是一个运行实体,有自己的地址空间,并占用一定的系统资源.简而言之,进程就是运行中的程序.在Linux中,诸如ls等命令都是进程,只不过某些命令 ...

  4. 基于 Koa平台Node.js开发的KoaHub.js的输出json到页面代码

    koahub-body-res koahub body res Format koa's respond json. Installation $ npm install koahub-body-re ...

  5. Vue学习之路---No.4(分享心得,欢迎批评指正)

    这里说声抱歉,周末因为有其他事,没有更新博客,那么我们今天继续上周5的说. 老规矩,先回顾一下上一次的重点: 1.利用V-if和v-else来提到show()和hide(),同时要记住,v-else一 ...

  6. 网络AFNetworking 3.1

    下面的类已从AFNetworking 3.0中废弃: AFURLConnectionOperation AFHTTPRequestOperation AFHTTPRequestOperationMan ...

  7. CoreAnimation 核心动画

    - (void)createBaseAnimation{ //基础动画 CABasicAnimation *animation = [CABasicAnimation animation]; anim ...

  8. Android 启动模式--任务(Task)--桟 的误区

    Android 启动模式--任务(Task)--桟 的误区 写这篇文章是因为前几天的一次面试,面试官说SingleInstance模式会新建一个桟,而SingleTask不会.首先不说这个对不对(非要 ...

  9. MyBatis:学习笔记(1)——基础知识

    MyBatis:学习笔记(1)--基础知识 引入MyBatis JDBC编程的问题及解决设想 ☐ 数据库连接使用时创建,不使用时就释放,频繁开启和关闭,造成数据库资源浪费,影响数据库性能. ☐ 使用数 ...

  10. UWP--页面传值

    //匿名对象 private void Button1_OnClick(object sender, RoutedEventArgs e) { , name = "LBI" }); ...