Spring Cloud 2020.0.0 正式发布,对开发者来说意味着什么?

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/2f/2f1b7b2df020b6b555e746cf143ce94d.png","alt":"头图.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作者 | ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"YourBatman  在线教育领域资深架构师,Spring Framework 开源贡献者","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"冷冷  云集架构师、开源项目 pig 负责人、Spring Cloud Alibaba Committer","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"来源|","attrs":{}},{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s/V6K6Ehq8xdRwnMbKJWG7_g","title":""},"content":[{"type":"text","text":"阿里巴巴云原生公众号","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"北京时间 2020 年 12 月 22 日深夜,","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"Spring Cloud 2020.0.0","attrs":{}}],"attrs":{}},{"type":"text","text":" 版本正式发布。2020.0.0 是第一个使用新版本命名方案的发命名的 Spring Cloud 发行版本。除了肉眼可见的更开发者友好的命名方式,这次发布全面抛弃了 Netflix 技术栈,并且是一个长期维护的主要版本。这对开发者来说意味着什么呢?","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"今天我们邀请到开源社区活跃作者 YourBatman 和 Spring Cloud Alibaba committer 冷冷来和大家解读下这次发版的重要变化,更重要的是和大家聊聊我们作为开发者后续应该如何应对","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"Spring Cloud 版本管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在 Spring Cloud 2020.0.0 正式发布之前,Spring Cloud 的 Release Train 名称采用的是伦敦地铁站名称来命名的,并以字母表顺序排列,如:Hoxton、Greenwich、Ilford 等,这种命名方式存在两个致命问题:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"对非英语","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"母语","attrs":{}},{"type":"text","text":"国家,比如中国就非常不友好,无法快速理清版本号关系","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"英文字母就 26 个,倘若版本号到了 Z 以后呢?如何继续发展?","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/7e/7e9037eafc0b493823696c3ca09531be.png","alt":"1.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud 遵循 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Pivotal OSS support policy","attrs":{}},{"type":"text","text":" 协议对","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"主要版本","attrs":{}},{"type":"text","text":"提供三年的支持。此外,在 Spring Cloud 的主要或次要版本发布后,若存在严重的 bug 和安全问题,就会再维护一段时间(6-12 个月不等)。参考以下表格:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/11/119d00f4af7cb8eae1140a8c3e64a99f.jpeg","alt":"2.jpg","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/27/27c9f585824d17e72e3101b272c737c5.jpeg","alt":"3.jpg","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"核心变化解读","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud 2020.0.0 作为一个","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"主要版本","attrs":{}},{"type":"text","text":",带来了众多显著的变化,其中进行了一些阻断式更新(不向下兼容)是本文最大看点,来吧上菜。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"核心变化一:再见了,Netflix","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"早在 2018 年,Spring Cloud 在其 Roadmap 里就宣布将要","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"终结","attrs":{}},{"type":"text","text":"的一些库/版本,其中最重要的就是指 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"Spring Cloud Netflix 项目进入维护模式","attrs":{}},{"type":"text","text":",然后计划在 2020 年完全移除。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud 做出这样的决定其实也是不见得是主动的。我们知道 Spring Cloud 一直以来把 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"Netflix OSS","attrs":{}}],"attrs":{}},{"type":"text","text":" 套件作为其官方默认的一站式解决方案,那时的 Netflix OSS 套件恨不得可以跟 Spring Cloud 划等号。而 Netflix 公司在 2018 年前后宣布其核心组件 Hystrix、Ribbon、Zuul、Archaius 等均进入","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"维护状态","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"时至今日,Spring Cloud 2020.0 正式发布,在这个主要版本里,按既定计划终于对 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-netflix","attrs":{}}],"attrs":{}},{"type":"text","text":" 动刀了。我帮你画了幅 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-netflix-dependencies","attrs":{}}],"attrs":{}},{"type":"text","text":" 的 xml 文件前后版本主要差异的对比图,一目了然:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/4a/4a3e4e91959fd94f385a9dfa080e2258.jpeg","alt":"4.jpg","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"旧版本的 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-netflix-dependencies","attrs":{}}],"attrs":{}},{"type":"text","text":" 管理着 Netflix 所有组件,包括 Hystrix、Ribbon、Zuul、Eureka 等。而自 2020.0 版本起它有且只管理 Eureka(包括 Server 和 Client)。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"核心变化二:继续业界标准制定,完善抽象定义","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可能对于大部分 Spring Cloud 应用开发者, 对于 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-commons","attrs":{}}],"attrs":{}},{"type":"text","text":" 模块大概很陌生。此模块作为 Spring Cloud 技术栈的核心,提供了整套解决方案最重要的服务注册与发现、负载均衡、上下文管理等的统一抽象。","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring cloud alibaba","attrs":{}}],"attrs":{}},{"type":"text","text":" 等全家桶实现都是 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-commons","attrs":{}}],"attrs":{}},{"type":"text","text":" 的具体实现。此版本对上文下启动器的默认启动行文、负载均衡器的核心代码进行相关的跳转。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":"spring-cloud-commons\n ├── actuator\n ├── circuitbreaker\n ├── discovery\n ├── hypermedia\n ├── loadbalancer\n └── serviceregistry","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"核心变化三:强推 reactive 异步体系","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"reactor 是 reactive(","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"反应式编程","attrs":{}},{"type":"text","text":")的实现框架,也是 Pivotal 团队的作品。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"无论是 Spring Cloud Gateway 还是 Spring Cloud Loadbalancer 这些都是构建在 reactor 编程之上。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e6/e60b9451c9ce4c2c9e1c9fb558e1e4cd.png","alt":"5.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"另外 Spring 官方布道师 Josh Long 最近出版一本 《Reactive Spring》,如果想深入了解 reactor ,不妨深入阅读。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"核心变化四:更好的拥抱云原生能力","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud 2020 构建在 Spring Boot 2.4 之上,拥有更强的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"配置文件处理机制","attrs":{}},{"type":"text","text":"可以非常好的适配云原生 (例如可以直接应用 kubernetes 的 configMap )配置;内置 Docker 镜像构建和分层分析优化能力。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果团队正在使用 kubernetes,那么 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-kubernetes","attrs":{}}],"attrs":{}},{"type":"text","text":" 也将是 Netflix 的不错替代方案。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/2e/2e734bf0784dafc1fec5d39726c83838.jpeg","alt":"6.jpg","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"组件替代方案","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud 既然把 Netflix 套件大刀阔斧的砍掉了,那总归得有替代方案吧。那是必然的,Spring Cloud 团队给我们推荐了用于替代的组件:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a9/a90805fc268b51d52b11ccf2926bbd2c.jpeg","alt":"7.jpg","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Spring Cloud LoadBalancer","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"以上替代品中,你可能最陌生、最好奇的是 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"Spring Cloud Loadbalancer","attrs":{}}],"attrs":{}},{"type":"text","text":",它一度只是 Spring Cloud ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"孵化器","attrs":{}},{"type":"text","text":"里的一个小项目,并且一度搁浅。后再经过重启,发展,现行使其伟大使命,正式用于","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"完全替换","attrs":{}},{"type":"text","text":" Ribbon,成为 Spring Cloud 负载均衡器","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"唯一实现","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/fd/fd70684992c4cc4488cb38b0b0f0e062.png","alt":"8.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如图,负载均衡抽象 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"LoadBalancerClient","attrs":{}}],"attrs":{}},{"type":"text","text":" 接口有两个实现,而到了 Spring Cloud 2020.0 版本后,","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"BlockingLoadBalancerClient","attrs":{}}],"attrs":{}},{"type":"text","text":" 就是唯一实现了。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud LoadBalancer 目前仅支持轮询负载均衡策略,相对于 Ribbon 多种高可用策略还是过于简单。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Spring Cloud Circuit Breaker","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Circuit Breaker 提供兼容多个断路器组件实现的抽象,允许开发人员选择最熟悉的断路器组件进行业务开发。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3d/3de3d07986ab9f578fb1805026d6663f.png","alt":"9.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"这里主要介绍一下 Sentinel、Resilience4j ,  Sentinel  作为 Spring Cloud Alibaba 重要组件,通过引入 ","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"spring-cloud-starter-alibaba-sentinel","attrs":{}},{"type":"text","text":"  即可拥有熔断降级、流控等能力,提供图形化控制台,作为同类组件 Resilience4j 是基于函数式设计的轻量级容错库,提供熔断、限流、隔离等能力,不过官方提供的 spring-cloud-starter-circuitbreaker-resilience4j 插件能力有限且不能直接使用控制台管理(若需监控需要额外的 Micrometer 服务)。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"Spring Cloud Alibaba 适配","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"由于对 Ribbon 组件的依赖,目前最新的 Spring Cloud Alibaba 2.2.3 并不能完全兼容 Spring Cloud 2020,仅需要微调即可。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":"// 排除 Ribbon (当然也可以排查 maven 依赖)\n@EnableAutoConfiguration(excludeName = \n\"org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration\")","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"增加 spring cloud loadbalancer 依赖。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":"\n org.springframework.cloud\n spring-cloud-starter-loadbalancer\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"涉及加载配置中心的服务需要 启动 bootstrap (2020 默认关闭)。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":"\n\n org.springframework.cloud\n spring-cloud-starter-bootstrap\n","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"以上调整可以参考 ","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/pig-mesh/pig/releases/tag/v3.0.0","title":""},"content":[{"type":"text","text":"兼容适配 Spring Cloud 2020 示例","attrs":{}}]},{"type":"text","text":"。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"开发者如何面对和拥抱变化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"正如上文所述 Spring Cloud 提供了强大的封装和抽象能力,例如 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-circuit-breaker","attrs":{}}],"attrs":{}},{"type":"text","text":" 提供了对常见容错组件的封装,在使用过程中也不需要考虑 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"@hystrixcommand","attrs":{}}],"attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"@SentinelResource","attrs":{}}],"attrs":{}},{"type":"text","text":" 组件原生注解。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":""},"content":[{"type":"text","text":"public static class DemoControllerService {\n private RestTemplate rest;\n private CircuitBreakerFactory cbFactory;\n public String slow() {\n return cbFactory.create(\"slow\").run(() -> rest.getForObject(\"/slow\", String.class), throwable -> \"fallback\");\n }\n}","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通过此类抽象底层实现组件的变化 ,对于上层使用 Spring Cloud 全家桶的用户其实影响不大(例如《Spring Cloud Alibaba 迁移指南:零代码从 Eureka 迁移到 Nacos》)。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"关于学习 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-commns","attrs":{}}],"attrs":{}},{"type":"text","text":" 笔者不建议直接阅读源码(部分 reactor 代码容易劝退),建议 DEBUG 具体实现的形式进行调试(例如 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"NacosDiscoveryClient","attrs":{}}],"attrs":{}},{"type":"text","text":"),最核心的代码不过百行。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/f6/f68a5677302b287bef47611293cd647d.png","alt":"10.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所以对于开发者来说无论是之前 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"Netflix","attrs":{}}],"attrs":{}},{"type":"text","text":" 还是选择 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"Alibaba","attrs":{}}],"attrs":{}},{"type":"text","text":" 技术栈,最核心的还是把握 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"spring-cloud-commons","attrs":{}}],"attrs":{}},{"type":"text","text":" 抽象,掌握 Spring Cloud 标准尤为重要。","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"总结","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Spring Cloud 2020.0.0 是 Spring Cloud 的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"主要版本","attrs":{}},{"type":"text","text":",是非常重要的存在,升级、改变也是巨大的。特别体现在 Netflix 模块的全部移除、Spring Cloud 启动方式变了等等。伴随着 Spring Boot 2.4.x 以及 Spring Cloud 2020.0 的发布,并且弃用 Netflix OSS 套件后,必将走入一个新的","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"深度编程","attrs":{}},{"type":"text","text":"体验,满怀惊喜,很是期待。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"当然我们还是非常推荐大家使用 Spring Cloud Alibaba 全家桶的,目前 Spring Cloud Alibaba 开源两年时间,已经从官方毕业,不仅在关注度、活跃上表现抢眼,更通过发布","attrs":{}},{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s/8FJQyoY6t1FWygsCJfxSeA","title":""},"content":[{"type":"text","text":"知行动手实验室 start.aliyun.com","attrs":{}}]},{"type":"text","text":" 提供沙箱和[ Java 工程脚手架](https://start.aliyun.com/bootstrap.html)、[Arthas 代码诊断工具](https://arthas.aliyun.com/zh-cn/)等成为工具链最完善的 Spring Cloud 实现。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/cd/cdadd607a258e503f75dc3c4d60c2569.png","alt":"11.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"数据来源:","attrs":{}},{"type":"link","attrs":{"href":"http://www.gharchive.org/","title":""},"content":[{"type":"text","text":"http://www.gharchive.org/","attrs":{}}]},{"type":"text","text":" 近2年GitHub开发者行为数据","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"活跃度计算公式:","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/X-lab2017/github-analysis-report-2019/blob/master/REPORT.md","title":""},"content":[{"type":"text","text":"https://github.com/X-lab2017/github-analysis-report-2019/blob/master/REPORT.md","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"推荐阅读","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s?_biz=MzI2ODYxMjU4MQ==&mid=2247484290&idx=1&sn=c1559d6381687d192ef9db1dcbad25cc&scene=21#wechatredirect","title":""},"content":[{"type":"text","text":"如何平滑将注册中心从 Eureka 迁移到 Nacos?","attrs":{}}]}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s?_biz=MzI4ODQ3NjE2OA==&mid=2247484416&idx=1&sn=064ad913b21d09d1333b08ab26dc7f17&scene=21#wechatredirect","title":""},"content":[{"type":"text","text":"Spring Cloud Alibaba 迁移指南1:零代码从 Eureka 迁移到 Nacos","attrs":{}}]}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://mp.weixin.qq.com/s?_biz=MzI1NTI3MzEwMg==&mid=2247495757&idx=2&sn=57d8d11e2d159f2984b31b71578b27ad&scene=21#wechatredirect","title":""},"content":[{"type":"text","text":"注册中心 Consul 迁移到 Nacos","attrs":{}}]}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"http://mp.weixin.qq.com/s?_biz=MzUzNzYxNjAzMg==&mid=2247492337&idx=1&sn=71df8eee2b4ab038a502bebcb2d3ced2&chksm=fae6e93ecd91602888cfee80041c6b37566a5e5cd1066df16439d320438c07a9375d3345554d&scene=21#wechatredirect","title":""},"content":[{"type":"text","text":"掌门教育微服务体系 Solar 第 3 弹:Nacos 企业级落地上篇","attrs":{}}]}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://github.com/sentinel-group/sentinel-website/blob/master/blog/zh-cn/sentinel-vs-hystrix.md","title":""},"content":[{"type":"text","text":"Sentinel 与 Hystrix 的对比","attrs":{}}]}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://github.com/sentinel-group/sentinel-website/blob/master/blog/zh-cn/guideline-migrate-from-hystrix-to-sentinel.md","title":""},"content":[{"type":"text","text":"Guideline: 从 Hystrix 迁移到 Sentinel","attrs":{}}]}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"活动推荐","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/b6/b6d95def895966e2918a21c842a6ff5b.png","alt":"12.png","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2021 年的首场 Spring Cloud Alibaba Meetup 城市站,我们邀请到了阿里中间件分布式事务团队负责人季敏、《深入理解 Spring Cloud 与实战》作者方剑、Apache Dubbo PMC 方银城、Nepxion 开源社区创始人任浩军、知名互联网公司中间件架构师童子龙 、七牛云技术经理姜智,一起畅聊 Go 语言、Spring 生态发展趋势,深度分享知名互联网教育公司微服务实战!","attrs":{}},{"type":"link","attrs":{"href":"https://www.huodongxing.com/event/2576519081911","title":""},"content":[{"type":"text","text":"点击此处","attrs":{}}]},{"type":"text","text":"即可报名参与~","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章