Spring Cloud Hoxton正式發佈,Spring Boot 2.2 不再孤單

距離Spring Boot 2.2.0的發佈已經有一個半月左右時間,由於與之匹配的Spring Cloud版本一直沒有Release,所以在這期間碰到不少讀者諮詢的問題都是由於Spring Boot和Spring Cloud版本不匹配導致。

很多時候,我們在學習或重建系統的時候都喜歡直接選用最高版本來開發,但是在使用Spring全家桶的時候,這樣的選擇不一定是最佳選擇。主要還是由於Spring全家桶中各項目之間還存在一定的依賴關係。尤其是在大版本迭代期間,是我們尤其要注意的。比如,這次Spring Framework、Spring Boot、Spring Cloud的升級,是一次整體的大版本的升級,涵蓋了Spring Framework 5.2、Spring Boot 2.2、Spring Cloud Hoxton。

由於Spring Boot 2.2基於Spring Framework 5.2構建,而Spring Cloud Hoxton又基於Spring Boot 2.2構建。所以,在Spring Cloud Hoxton發佈Release版本之前,出現了很多Spring Boot 2.2搭配Spring Cloud Greenwich版本使用而出現各種莫名問題的情況。

現在Spring Cloud Hoxton的正式發佈,也預示著Spring Cloud用戶可以正式開始往Spring Boot 2.2.x版本進行逐步升級。

Spring Cloud Hoxton版本內容

下面我們來關注下在Spring Cloud Hoxton版本中都提升了哪些內容。先來看看這次各依賴項目的版本升級:

Spring Cloud Aws 2.2.0.RELEASESpring Cloud Vault 2.2.0.RELEASESpring Cloud Circuitbreaker 1.0.0.RELEASESpring Cloud Cli 2.2.0.RELEASESpring Cloud Gateway 2.2.0.RELEASESpring Cloud Zookeeper 2.2.0.RELEASESpring Cloud Starter Hoxton.RELEASESpring Cloud Build 2.2.0.RELEASESpring Cloud Config 2.2.0.RELEASESpring Cloud Dependencies Parent 2.2.0.RELEASESpring Cloud Starter Parent Hoxton.RELEASESpring Cloud Sleuth 2.2.0.RELEASESpring Cloud Contract 2.2.0.RELEASESpring Cloud Gcp 1.2.0.RELEASESpring Cloud Bus 2.2.0.RELEASESpring Cloud Consul 2.2.0.RELEASESpring Cloud Stream Horsham.RELEASESpring Cloud Kubernetes 1.1.0.RELEASESpring Cloud Openfeign 2.2.0.RELEASESpring Cloud Commons 2.2.0.RELEASESpring Cloud Dependencies Hoxton.RELEASESpring Cloud Task 2.2.0.RC1Spring Cloud Function 3.0.0.RELEASESpring Cloud Hoxton.RELEASESpring Cloud Netflix 2.2.0.RELEASESpring Cloud Security 2.2.0.RELEASESpring Cloud Release Hoxton.RELEASESpring Cloud Cloudfoundry 2.2.0.RELEASE

在這次的版本升級中,我覺得以下幾點是非常值得讀者關注和學習的:

新的負載均衡器實現

Spring Cloud Hoxton版本中第一次引入同時支持阻塞式與非阻塞式的負載均衡器來作為已經進入維護狀態的Netflix Ribbon。

通過引入org.springframework.cloud:spring-cloud-loadbalancer依賴,你就可以將新的BlockingLoadBalancerClient與RestTemplate一起使用了。

同時,該依賴的引入也將支持Reactive應用,跟其他使用一樣,只需要使用@LoadBalanced來修飾WebClient.Builder即可。

新的斷路器實現

該項目中定義了斷路器的抽象API,以及對各開源實現的整合封裝,其中包括:

Resilience4jSpring RetryHystrix (spring-cloud-netflix)Sentinel (spring-cloud-alibaba)

加入更多Reactive支持

Spring Cloud Gateway中增加ReactiveLoadBalancer以下組件中增加ReactiveDiscoveryClient服務發現實現: Spring Cloud Netflix Spring Cloud Consul Spring Cloud Zookeeper Spring Cloud Openfeign Spring Cloud Cloudfoundry Spring Cloud Kubernetes

相關閱讀

http://blog.didispace.com/spring-boot-2-2-release/http://www.didispace.com/2019/11/07/spring-boot-2-2-1-release/http://blog.didispace.com/spring-cloud-learning/