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}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章