spring-cloud

Eureka搭建集群

耗尽温柔 提交于 2020-02-07 07:33:19
搭建服务端集群 1 创建工程并引入相关依赖 < ? 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 . fangxing . springcloud < / groupId > < artifactId > euruka - server < / artifactId > < version > 0.0 .1 - SNAPSHOT < / version > < packaging > jar < / packaging > < name > euruka - server < / name > < description > Demo project for Eureka Server < /

Consul with Spring Cloud Gateway - Inter Service Communication

时光总嘲笑我的痴心妄想 提交于 2020-02-07 06:01:27
问题 The setup: I have a set of Spring Boot based microservices that are fronted by Spring Cloud Gateway, meaning every request that comes from UI or external API client first comes to Spring Cloud Gateway and is then forwarded to appropriate microservice. The routes are configured in Consul, and Spring Cloud Gateway communicates with Consul to get the routes accordingly. Requirement: There is a need of some microservices communicating with each other with REST APIs. I would prefer this

springcloud(十六):服务网关 Spring Cloud GateWay 服务化和过滤器

狂风中的少年 提交于 2020-02-05 19:00:20
上一篇文章 服务网关 Spring Cloud GateWay 初级篇 ,介绍了 Spring Cloud Gateway 的相关术语、技术原理,以及如何快速使用 Spring Cloud Gateway。这篇文章我们继续学习 Spring Cloud Gateway 的高级使用方式,比如如何配置服务中心来使用,如何使用熔断、限流等高级功能。 注册中心 上篇主要讲解了网关代理单个服务的使用语法,在实际的工作中,服务的相互调用都是依赖于服务中心提供的入口来使用,服务中心往往注册了很多服务,如果每个服务都需要单独配置的话,这将是一份很枯燥的工作。Spring Cloud Gateway 提供了一种默认转发的能力,只要将 Spring Cloud Gateway 注册到服务中心,Spring Cloud Gateway 默认就会代理服务中心的所有服务,下面用代码演示。 准备服务和注册中心 在介绍 服务网关 zuul 的使用 时,提供了 spring-cloud-eureka 、spring-cloud-producer 项目示例,本次演示我们将两个项目版本升级到 Finchley.SR2 后继续演示使用。 spring-cloud-eureka(Eureka Server) 的 pom 文件更改,其它依赖包不变。 升级前: <dependency> <groupId>org

org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class

安稳与你 提交于 2020-02-04 10:22:13
遇到了,解决了,记录一下 这个问题是jar版本问题,ServerPropertiesAutoConfiguration,在springboot 2.x.x 以后移除了,当springboot>=2.x.x ,其他jar包加载 涉及到ServerPropertiesAutoConfiguration 就会报错了,比如我引用如下,就会报错, <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> <version>1.4.7.RELEASE</version> </dependency> 替换成 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> 就可以了,spring-cloud-starter-feign 中除去spring-cloud-starter-openfeign 外还有spring-boot-autoconfigure-processor 包 来源: CSDN 作者: 下刀 链接: https://blog

Spring cloud streams could not autowire Source.class

痴心易碎 提交于 2020-02-02 15:42:50
问题 I am learning Spring Cloud Streams from scratch. I tried to create a Source application like this: import org.springframework.cloud.stream.messaging.Source; //etc @RestController @SpringBootApplication @CrossOrigin @EnableBinding(Source.class) public class StreamsProducerApplication { @Autowired Source source; @GetMapping(value="/send/{message}") public void sendMessage(@PathVariable String message){ if(message != null){ source.output().send(MessageBuilder.withPayload(message).build());} }

SpringCloud H系列 alibaba 2.1.1 (三) sentinel 限流熔断(基于Feign)

家住魔仙堡 提交于 2020-01-30 03:50:48
1.nacos安装 请参考 : docker 安装 nacos 1.X 2.项目父工程 请参考 : SpringCloud H系列 alibaba 2.1.1 (一) nacos1.X 注册中心 服务端 3.项目结构 4.创建Feign 服务调用端 pom.xml <parent> <groupId>com.alibaba</groupId> <artifactId>spring-cloud-hoxton</artifactId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>alibaba-sentinel-feign-server</artifactId> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos

Spring Cloud Zuul/Eureka dynamic route

一笑奈何 提交于 2020-01-28 21:00:02
问题 I am using spring cloud eureka and spring cloud zuul proxy and i was wondering if there is any way to add dymanic zuul routes when a new service is register in eureka server or the only way to add a route is edit the application.yml file and restart the spring zuul application zuul: ignoredPatterns: /**/admin/** routes: users: /myusers/** 回答1: If your Zuul server is also EurekaClient (use @EnableDiscoveryClient annotation) it will discover all the services and automatically will create routes

Spring Cloud Zuul/Eureka dynamic route

假如想象 提交于 2020-01-28 20:59:31
问题 I am using spring cloud eureka and spring cloud zuul proxy and i was wondering if there is any way to add dymanic zuul routes when a new service is register in eureka server or the only way to add a route is edit the application.yml file and restart the spring zuul application zuul: ignoredPatterns: /**/admin/** routes: users: /myusers/** 回答1: If your Zuul server is also EurekaClient (use @EnableDiscoveryClient annotation) it will discover all the services and automatically will create routes

Zuul Filter遇到的HttpHostConnectException cannot be cast to ZuulException问题解决方法

时光毁灭记忆、已成空白 提交于 2020-01-28 19:02:16
HttpHostConnectException cannot be cast to ZuulException问题解决方法 SpringBoot 2.0.3 / Cloud 版本 Finchley.RELEASE 当Zuul对应服务宕机后,加载相应网关地址可能会报以下错误 org.apache.http.conn.HttpHostConnectException cannot be cast to com.netflix.zuul.exception.ZuulException 经排查,2.0.1以下版本的spring-cloud-starter-netflix-zuul依赖存在这个Bug 需要使用2.0.1及以上的版本 同时,在spring-cloud-starter-netflix-zuul中包含了spring-cloud-netflix-zuul包,但更改starter-netflix-zuul的版本时spring-cloud-netflix-zuul可能并不会跟着修改,同样需要spring-cloud-netflix-zuul版本为2.0.1以上 所以可按如下方式引入包 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix