
SpringCloud
悠悠-我心
水不撩不知深浅,人不拼不知输赢。
展开
-
spring cloud-Feign使用中遇到的问题总结
问题一:在前面的示例中,我们讲过[java] view plain copy@RequestMapping(value = "/user/{id}", method = RequestMethod.GET) @GetMapping("/user/{id}") 这两个注解的效果是等价的,但是在Feign使用中,只能用上面的那种方式,不能直接用@GetMapping,下面我们将前面的那个示例中,改...原创 2018-02-28 23:59:14 · 1791 阅读 · 0 评论 -
理解微服务注册到Eureka Server上的过程(以appname为例)
阅读本文你将了解微服务注册到Eureka Server上的粗粒度过程为什么appname是大写。appName的配置:spring.application.name与eureka.instance.appname,及它们的优先级。Prepare首先解释一下什么是appname图中的MICROSERVICE-PROVIDER-USER就是appname。下面我们来分析一下它的详细逻辑。分析(1) 首...转载 2018-03-16 14:50:10 · 4611 阅读 · 3 评论 -
Docker容器双向联通与高可用的Eureka Server
在《4.7 Eureka Server的高可用》中,我们构建了一个双节点的Eureka Server集群,本节我们使用Compose来编排这个Eureka Server集群。该双节点的Eureka配置如下:spring: application: name: microservice-discovery-eureka-ha---spring: profiles: peer1 ...转载 2018-03-16 14:49:42 · 1587 阅读 · 0 评论 -
解决Spring Cloud Bus不刷新所有节点的问题及理解"Application Context ID must be unique"
如果同一微服务的多个实例使用的端口相同,当配置修改时,使用Spring Cloud Bus不会刷新全部实例的配置。此时需要配置各个实例的spring.application.index为不同的值。下面我们来分析一下原因。在Spring Cloud Config上有这么一段:Application Context ID must be uniqueThe bus tries to eliminate...转载 2018-03-16 14:49:05 · 815 阅读 · 0 评论 -
将应用的log4j换成logback
考虑到log4j很久不更新、性能相对弱,以及一些项目本身的原因,经过较为谨慎的考虑,决定改用logback。迁移还是比较顺利的,花了1个小时左右就搞定了,做个简单的笔记。(1) 首先去掉所有log4j相关的依赖,主要有:<dependency> <groupId>log4j</groupId> <artifactId>log4j</arti...转载 2018-03-16 14:48:24 · 339 阅读 · 0 评论 -
应用无法启动,并且不报错的总结log4j的问题
应用启动不起来,并且不报错。没有任何征兆与线索。经过排查,是log4j的问题,log4j配置如下。log4j.rootLogger = INFO,console,logstashlog4j.logger.com.atc=INFOlog4j.appender.console=org.apache.log4j.ConsoleAppenderlog4j.appender.console.target=S...转载 2018-03-16 14:47:48 · 998 阅读 · 0 评论 -
Spring Cloud中,Feign常见问题总结
Spring Cloud中,Feign常见问题的总结。FeignClient接口,不能使用@GettingMapping 之类的组合注解代码示例:@FeignClient("microservice-provider-user")public interface UserFeignClient { @RequestMapping(value = "/simple/{id}", method = ...转载 2018-03-16 14:46:56 · 395 阅读 · 0 评论 -
Spring Cloud中,如何解决Feign/Ribbon第一次请求失败的问题?
Spring Cloud中,Feign和Ribbon在整合了Hystrix后,可能会出现首次调用失败的问题,要如何解决该问题呢?造成该问题的原因Hystrix默认的超时时间是1秒,如果超过这个时间尚未响应,将会进入fallback代码。而首次请求往往会比较慢(因为Spring的懒加载机制,要实例化一些类),这个响应时间可能就大于1秒了。知道原因后,我们来总结一下解决放你。解决方案有三种,以feig...转载 2018-03-16 14:46:09 · 452 阅读 · 1 评论 -
Spring Cloud中,Eureka常见问题总结
Spring Cloud中,Eureka常见问题总结。指定Eureka的Environmenteureka.environment: 指定环境参考文档:https://github.com/Netflix/eureka/wiki/Configuring-Eureka指定Eureka的DataCentereureka.datacenter: 指定数据中心参考文档:https://github.com...转载 2018-03-16 14:45:32 · 254 阅读 · 0 评论 -
Spring Cloud第二篇 创建一个Eureka Server
在Spring Cloud实现一个Eureka Server是一件非常简单的事情。下面我们来写一个Eureka Server DEMO。编码(1) 首先创建一个Maven工程,添加内容如下:<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x...转载 2018-03-16 14:44:36 · 388 阅读 · 0 评论 -
Spring Cloud第一篇 Eureka简介及原理
Eureka是Netflix开发的服务发现组件,本身是一个基于REST的服务。Spring Cloud将它集成在其子项目spring-cloud-netflix中,以实现Spring Cloud的服务发现功能。目前Eureka 项目相当活跃,代码更新相当频繁,目前最新的版本是1.5.5。Eureka 2.0也在紧锣密鼓地开发中,2.0将会带来更强的功能和更好的扩展性,但是由于还没有Release,...转载 2018-03-16 14:44:03 · 273 阅读 · 0 评论 -
SpringCloud 解决第一次请求Eureka报超时异常的方案
# 解决第一次请求报超时异常的方案:# hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000# 或者:# hystrix.command.default.execution.timeout.enabled: false# 或者:feign.hystrix.enabled: false ## 索性...原创 2018-03-01 00:29:39 · 5514 阅读 · 1 评论