距离 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.RELEASE
- Spring Cloud Vault 2.2.0.RELEASE
- Spring Cloud Circuitbreaker 1.0.0.RELEASE
- Spring Cloud Cli 2.2.0.RELEASE
- Spring Cloud Gateway 2.2.0.RELEASE
- Spring Cloud Zookeeper 2.2.0.RELEASE
- Spring Cloud Starter Hoxton.RELEASE
- Spring Cloud Build 2.2.0.RELEASE
- Spring Cloud Config 2.2.0.RELEASE
- Spring Cloud Dependencies Parent 2.2.0.RELEASE
- Spring Cloud Starter Parent Hoxton.RELEASE
- Spring Cloud Sleuth 2.2.0.RELEASE
- Spring Cloud Contract 2.2.0.RELEASE
- Spring Cloud Gcp 1.2.0.RELEASE
- Spring Cloud Bus 2.2.0.RELEASE
- Spring Cloud Consul 2.2.0.RELEASE
- Spring Cloud Stream Horsham.RELEASE
- Spring Cloud Kubernetes 1.1.0.RELEASE
- Spring Cloud Openfeign 2.2.0.RELEASE
- Spring Cloud Commons 2.2.0.RELEASE
- Spring Cloud Dependencies Hoxton.RELEASE
- Spring Cloud Task 2.2.0.RC1
- Spring Cloud Function 3.0.0.RELEASE
- Spring Cloud Hoxton.RELEASE
- Spring Cloud Netflix 2.2.0.RELEASE
- Spring Cloud Security 2.2.0.RELEASE
- Spring Cloud Release Hoxton.RELEASE
- Spring Cloud Cloudfoundry 2.2.0.RELEASE
在这次的版本升级中, 我觉得以下几点是非常值得读者关注和学习的:
新的负载均衡器实现
Spring Cloud Hoxton 版本中第一次引入同时支持阻塞式与非阻塞式的负载均衡器来作为已经进入维护状态的 Netflix Ribbon.
通过引入 org.springframework.cloud:spring-cloud-loadbalancer 依赖, 你就可以将新的 BlockingLoadBalancerClient 与 RestTemplate 一起使用了.
同时, 该依赖的引入也将支持 Reactive 应用, 跟其他使用一样, 只需要使用 @LoadBalanced 来修饰 webClient.Builder 即可.
新的断路器实现
该项目中定义了断路器的抽象 API, 以及对各开源实现的整合封装, 其中包括:
- Resilience4j
- Spring Retry
- Hystrix (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
来源: https://www.cnblogs.com/didispace/p/12013055.html