spring-cloud

How to config multiple Eureka Servers from client in Spring Cloud

谁说胖子不能爱 提交于 2019-11-27 00:53:12
问题 From the spring doc, I see we can have peer eureka server together, so for Eureka1, in application.yml, I can have: spring: profiles: peer1 eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: http://peer2/eureka/ And in Eureka Server 2, I can have: spring: profiles: peer2 eureka: instance: hostname: peer2 client: serviceUrl: defaultZone: http://peer1/eureka/ Now these two eureka servers are aware each other, it is good. BUT, now in configuring client, when they register again

Using Zuul as an authentication gateway

元气小坏坏 提交于 2019-11-27 00:02:46
问题 Background I want to implement the design presented in this article. It can be summarised by the diagram below: The client first authenticate with the IDP (OpenID Connect/OAuth2) The IDP returns an access token (opaque token with no user info) The client makes a call through the API gateway use the access token in the Authorization header The API gateway makes a request to the IDP with the Access Token The IDP verifies that the Access Token is valid and returns user information in JSON format

Spring Cloud Configuration Server not working with local properties file

别等时光非礼了梦想. 提交于 2019-11-26 20:17:07
问题 I have been playing around with the Spring Cloud project on github located here: https://github.com/spring-cloud/spring-cloud-config However I have been running into some problems getting it to read a local properties file instead of pulling the properties from github. It seems that spring is ignoring the local file even when I remove all the references to github. There is a similar question posted here: Spring-Cloud configuration server ignores configuration properties file But I haven't

Customizing Zuul Exception

雨燕双飞 提交于 2019-11-26 17:28:19
问题 I have a scenario in Zuul where the service that the URL is routed too might be down . So the reponse body gets thrown with 500 HTTP Status and ZuulException in the JSON body response. { "timestamp": 1459973637928, "status": 500, "error": "Internal Server Error", "exception": "com.netflix.zuul.exception.ZuulException", "message": "Forwarding error" } All I want to do is to customise or remove the JSON response and maybe change the HTTP status Code. I tried to create a exception Handler with

How do you create custom zuul filters in spring cloud

陌路散爱 提交于 2019-11-26 17:05:40
问题 I want to write some of my own custom zuul filters for a spring cloud microservice i am writing. Once i have the filter written how do I integrate it so the underlying netflix zuul framework can take advantage of it. 回答1: Create a @Bean that extends ZuulFilter . See java configuration examples here. As long as the bean is in the same context as the @EnableZuulProxy app, it will automatically get picked up. @Bean public MyFilter myFilter() { return new MyFilter(); } See examples of filters

Spring Cloud 入门之一. 服务注册

若如初见. 提交于 2019-11-26 14:37:33
使用Config Server,您可以在所有环境中管理应用程序的外部属性。客户端和服务器上的概念映射与Spring Environment 和 PropertySource 抽象相同,因此它们与Spring应用程序非常契合,但可以与任何以任何语言运行的应用程序一起使用。随着应用程序通过从开发人员到测试和生产的部署流程,您可以管理这些环境之间的配置,并确定应用程序具有迁移时需要运行的一切。服务器存储后端的默认实现使用git,因此它轻松支持标签版本的配置环境,以及可以访问用于管理内容的各种工具。很容易添加替代实现,并使用Spring配置将其插入 以上是Spring Cloud官网对配置服务的描述, 简单阐述一下我的理解。比如我们要搭建一个网站,需要配置数据库连接,指定数据库服务器的IP地址,数据库名称,用户名和口令等信息。通常的方法, 我们可以在一个配置文件中定义这些信息,或者开发一个页面专门配置这些东西。只有一个web服务器的时候, 很方便。 但假如需要搭建同多台服务器时,当然可以每台服务器做同样配置,但维护和同步会很麻烦。我理解的配置服务至少有两种不同场景: 1). 多个客户使用同一配置: 比如,多台服务器组成的集群,假如后端使用同一数据库,那么每台服务器都是用相同的配置。 2). 不同客户使用不同的配置: 比如典型的场景是,开发,测试,生产使用相同的系统,但使用不同的数据库

SpringCloud配置中心--git版

倾然丶 夕夏残阳落幕 提交于 2019-11-26 14:14:46
今天,日月教大家如何配置git版的spring-cloud-config配置中心,这里只讲server端,因为其他的都和之前发的svn版的一样。话不多说直接上代码。 1、先在码云上创建一个仓库 并提交一个配置文件,里面配置hello: git-config-test 当然,有条件的同学,也可以自己搭建gitlab服务器。 2、创建spring-cloud-config-server项目 pom依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-amqp</artifactId> </dependency> 配置文件application.yml

Eureka Client 注册报 registration status: 204

北慕城南 提交于 2019-11-26 01:07:16
今天在学习Eureka的时候发现注册Client端总是注册不到注册中心,并且也启动不起来,总是出现registration status: 204 这个错误。 异常信息: "E:\Program Files\Java\jdk1.8.0_171\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55838,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=55837 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "E:\Program Files\Java\jdk1.8.0_171\jre\lib

springboot 集成eureka 超详细配置

独自空忆成欢 提交于 2019-11-25 23:19:13
撸了今年阿里、头条和美团的面试,我有一个重要发现.......>>> 原文链接: https://blog.csdn.net/nanbiebao6522/article/details/80574463 就不重复造轮子了, 以下是原文: 前言 1,什么是Eureka,什么是服务注册与发现 Spring Boot作为目前最火爆的web框架。那么它与Eureka又有什么关联呢? Eureka是Netflix开源的一个RESTful服务,主要用于服务的注册发现。 Eureka由两个组件组成:Eureka服务器和Eureka客户端。Eureka服务器用作服务注册服务器。 Eureka客户端是一个java客户端,用来简化与服务器的交互、作为轮询负载均衡器,并提供服务的故障切换支持。 Netflix在其生产环境中使用的是另外的客户端,它提供基于流量、资源利用率以及出错状态的加权负载均衡。 2,先创建一个Eureka-Server服务注册中心 这里需要用到spring-cloud的Eureka模块,他是一个服务的注册和发现模块 如图我们先new一个Spring-boot工程引入Eureka Server Next>>>>Finish完成 我们来看看构建好的Eureka-Server的pom.xml代码 <?xml version="1.0" encoding="UTF-8"?> <project