spring-cloud

spring-cloud 平滑升级 踩坑记录

╄→гoц情女王★ 提交于 2019-11-30 03:21:54
1、eureka 客户端 添加配置 endpoints.pause.enabled=true endpoints.pause.sensitive=false #\u542F\u7528shutdown endpoints.shutdown.enabled=true #\u7981\u7528\u5BC6\u7801\u9A8C\u8BC1 endpoints.shutdown.sensitive=false # \u7981\u7528actuator\u7BA1\u7406\u7AEF\u9274\u6743 management.security.enabled=false # \u5F00\u542F\u91CD\u542F\u652F\u6301 endpoints.restart.enabled=true 2、注意配置 eureka.client.healthcheck.enabled=true management.contextPath=/management 而当我们设置配置 eureka.client.healthcheck.enabled=true 的时候,即使调用 /pause 端点,Eureka上服务的状态也会是 UP 注:当应用在Eureka Server上的状态已被标记为 DOWN ,但是应用本身其实依然是可以正常对外服务的,并没有被关闭

Spring Cloud Config Server Can't locate PropertySource on startup

岁酱吖の 提交于 2019-11-30 01:58:02
问题 When I start my Spring Cloud Config Server I get the following error. Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/configserver/default/master":Connection refused; nested exception is java.net.ConnectException: Connection refused However when I hit that URL in my browser it exists and the config server is working. What is going on? application.yml server: port: 8888 management: context-path: /admin logging: level: com.netflix.discovery: 'OFF' org

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?

我们两清 提交于 2019-11-29 18:35:36
What is the difference between putting a property on application.yml or bootstrap.yml in spring boot? In logging.config case, the application works different. Michael Isvy I have just asked the Spring Cloud guys and thought I should share the info I have here. bootstrap.yml is loaded before application.yml . It is typically used for the following: when using Spring Cloud Config Server, you should specify spring.application.name and spring.cloud.config.server.git.uri inside bootstrap.yml some encryption/decryption information Technically, bootstrap.yml is loaded by a parent Spring

spring-cloud-kubernetes官方demo运行实战

守給你的承諾、 提交于 2019-11-29 18:21:28
关于spring-cloud-kubernetes spring-cloud-kubernetes是springcloud官方推出的开源项目,用于将Spring Cloud和Spring Boot应用运行在kubernetes环境,并且提供了通用的接口来调用kubernetes服务,GitHub上官方地址是: https://github.com/spring-cloud/spring-cloud-kubernetes 系列文章列表 本文是《spring-cloud-kubernetes实战系列》的第一篇,全文链接如下: 《spring-cloud-kubernetes官方demo运行实战》 《你好spring-cloud-kubernetes》 《spring-cloud-kubernetes背后的三个关键知识点》 《spring-cloud-kubernetes的服务发现和轮询实战(含熔断)》 《spring-cloud-kubernetes与SpringCloud Gateway》 《spring-cloud-kubernetes与k8s的configmap》 官方demo 官方提供了简单的demo用于快速了解spring-cloud-kubernetes,但是成功运行此demo需要做一些设置和修改,这也是此文的意义所在,接下来我们一起实战这个demo; 环境信息

inter micro-service request responds with Forbidden status in spring cloud application

久未见 提交于 2019-11-29 18:17:27
I am investigating microservice architecture. I chose the spring cloud framework. My application shema looks like this: Also I have discovery server eureka but I decided to skip on the picture to simplify it. Full source code of example you can find on githib: https://github.com/gredwhite/spring-cloud Problem explanation: hello world service: @GetMapping("/helloWorld") @HystrixCommand(fallbackMethod = "reliable") public String hello() { return this.restTemplate.getForObject("http://hello-service/hello?name=World", String.class); } hello service: @GetMapping("/hello") public String hello(

spring-cloud学习笔记基于spring-boot2.0.3--Eureka注册中心(二)集群方式部署

旧巷老猫 提交于 2019-11-29 17:42:19
上篇我们介绍了Eureka的注册中心的搭建,注册中心是整个微服务架构的一个核心组件,如果只是单节点的应用,一旦出现注册中心挂掉的情况,那么会造成服务之间的不可调用。所以在生成环境中一般都会采用集群的部署方式。 在上一篇博客的基础上改造:博客地址: https://blog.csdn.net/zhuwei_clark/article/details/82114299 复制application.yml文件,复制三份,分别命令为:application-peer1.yml,application-peer2.yml,application-peer3.yml 修改配置application-peer1.yml文件内容: 修改端口:9001 修改配置application-peer2.yml文件内容: 修改端口:9002 修改配置application-peer3.yml文件内容: 修改端口:9003 使用maven进行打包,在target的目录下生成对应的vts_sc_eureka.jar包。 同步改jar包到指定的服务器上。 编写启动命令 java -jar vts_sc_eureka-1.0.jar &> /home/data/log/peer1.log --spring.profiles.active=peer1 java -jar vts_sc_eureka-1.0.jar &

微服务SpringCloud之服务网关zuul一

纵饮孤独 提交于 2019-11-29 17:35:39
前面学习了Eureka、Feign、Hystrix、Config,本篇来学习下API网关zuul。在微服务架构中,后端服务往往不直接开放给调用端,而是通过一个API网关根据请求的url,路由到相应的服务。当添加API网关后,在第三方调用端和服务提供方之间就创建了一面墙,这面墙直接与调用方通信进行权限控制,后将请求均衡分发给后台服务端。 为什么需要API Gateway 1、简化客户端调用复杂度 在微服务架构模式下后端服务的实例数一般是动态的,对于客户端而言很难发现动态改变的服务实例的访问地址信息。因此在基于微服务的项目中为了简化前端的调用逻辑,通常会引入API Gateway作为轻量级网关,同时API Gateway中也会实现相关的认证逻辑从而简化内部服务之间相互调用的复杂度。 2、数据裁剪以及聚合 通常而言不同的客户端对于显示时对于数据的需求是不一致的,比如手机端或者Web端又或者在低延迟的网络环境或者高延迟的网络环境。 因此为了优化客户端的使用体验,API Gateway可以对通用性的响应数据进行裁剪以适应不同客户端的使用需求。同时还可以将多个API调用逻辑进行聚合,从而减少客户端的请求数,优化客户端用户体验 3、多渠道支持 当然我们还可以针对不同的渠道和客户端提供不同的API Gateway,对于该模式的使用由另外一个大家熟知的方式叫Backend for front-end

EnableOAuth2Sso simultaneously for multiple social networks

五迷三道 提交于 2019-11-29 15:48:27
I am implementing a spring boot application that needs to provide OAuth2 token authorization and support multiple social services (google+, facebook etc). The user should be able to select his preferred social network and sign-in using the OAuth2 authorization framework. I am implementing the above using the approach described here http://cloud.spring.io/spring-cloud-security/ . Currently my application.yml looks like this spring: oauth2: client: clientId: {{my app's google id} clientSecret: {{my app's google secret code}} etc... Also, the spring boot main class is annotated as

How spring cloud config use local property override remote property

本小妞迷上赌 提交于 2019-11-29 14:11:49
问题 I know should set following properties, but still confused about where they should be set. spring: cloud: config: allowOverride: true failFast: true overrideNone: false application.properties file on spring cloud server side or client side or remote git repository? I set them in application.yml on server side, but don't work. I try set in application.yml on remote git, and again not work, hope you could give me some help, thanks. 回答1: I set the following configurations in remote git repo. It

Mock an Eureka Feign Client for Unittesting

痞子三分冷 提交于 2019-11-29 12:36:26
问题 i am using spring cloud's eureka and feign to communicate between some services (lets say A and B). Now id like to unittest my service layer of a single service (A). The problem is, that this service (A) is using a feign client to request some information of the other service (B). Running the unittests without any special configuration throws the following exception: java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: