iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 30
0
Software Development

30天從零開始 使用 Spring Boot 跟 Spring Cloud 建構完整微服務架構系列 第 30

Day 30 - SpringBoot 2.0 跟發展

目前 SpringBoot 2.0 正在 RC1 Spring Boot 2.0 Release Notes
印象中是比預定發布晚了, 但感覺也差不多要出來了.
但這個到底值不值得升版上去呢?

讓我們看一下幾個要點

  1. Reactive Support
    SpringBoot 2.0 的基礎是基於 Spring Framework 5.0, 所以 5.0 支援的東西, 它當然也會有, 那這東西 大陸那邊翻譯叫響應式? 好吧...中文是還蠻準確傳達的XD, 我大概理解就是你可以當成一個完全異步的框架 就好比是 NodeJS, 你可以在 http://start.spring.io 列表這邊看到一票組建在2.0都換成支援 Reactive 的套件了, 有些則是連底層驅動都換了.
    SpringBoot套件列表
    那這個代表你一些耗時的計算或是取得遠端資料等等作業, 可以不必浪費資源在那邊等, 也就是說你可以處理更多 Request 請求了, 你可以來這邊看看比較 Raw Performance Numbers - Spring Boot 2 Webflux vs. Spring Boot 1

  2. Java 8 Baseline
    Spring Boot 2.0 is going to require that you run Java 8. This means that Java 6 & 7 will no longer be supported. My guess is that one of the 1.5.x releases will be the last version to support this. I also am excited that Java 9 is going to be supported as well.

(早就升的沒什麼感覺)

  1. New Gradle Plugin
    Spring Boot’s Gradle plugin no longer automatically applies the dependency management plugin. Instead, Spring Boot’s plugin now reacts to the dependency management plugin being applied by importing the correct version of the spring-boot-dependencies bom. This gives you more control over how and when dependency management is configured.

https://spring.io/blog/2017/04/05/spring-boot-s-new-gradle-plugin
(目前還沒用到)

  1. Thymeleaf 3
    首先效能改善一定是廢話跳過, 作為官方推薦的模板引擎, 一定要配合一些新特性啊, 也就是配合 Spring 5 的一些功能整合啊, 例如下面這個鏈結 搭配 WebFlux 的模板引擎
    Interface ISpringWebFluxTemplateEngine
  • Full, producing all output in memory and sending it as a single output buffer.
  • Chunked, producing output in buffers (chunks) of a configurable maximum size and sending them to the client as they are produced.
  • Data-Driven, making Thymeleaf work as an integrated part of a reactive stream of data, rendering HTML for the produced data in a way fully sensible to reactive back-pressure, sending HTML chunks of output to the client as data is produced (and optionally shaping this HTML chunks into SSE events).
  1. @ConditionalOnBean
    @ConditionalOnBean now uses a logical AND rather than a logical OR when determining whether or not the condition has been met.
    (目前還沒用到)

  2. JUnit 5
    全新開發的 JUnit 5 絕對要找機會試試, 這個良葛格有寫過介紹文章 快速看一眼JUnit 5

  3. Custom Endpoints
    對監控來說蠻重要的, 以前只有官方預設的 actuator beans env health....等, 現在可以自訂了 Spring Boot 2.0 Will Feature Improved Actuator Endpoints

大概列出而已, 其實有些還沒用到也沒什麼感覺, 不過主要就是 Reactive Support 吧, 光是這個就蠻值得了, 以前要做也不是不行就還蠻麻煩的, 現在有框架層級的支援, 應該會更好處理吧.

其實在那邊吵語言或是框架, 其實意義沒有很大, 效能或許是一種指標, 但也不是絕對, 主要還是看整個生態 社群 是否活躍吧, 可以持續改善下去才有意義, 不然到最後被棄坑了......就悲劇了.

從 SpringBoot 推出 到整併 Netflix OSS 後推出 SpringCloud 又出了 Spring 5 現在要準備出的 SpringBoot 2, 感覺也不過 4 年, 接下來一票組件也會更新吧? 我第一篇 SpringBoot 文章是在 2014 的 使用Spring-Boot快速建構Web應用
你可以感覺還是蠻活躍的, 至少再戰個 10 年 20 年沒什麼問題XD

再來 說微服務這塊, 整併 Netflix 既有的東西, 基本上架構是已被驗證過的,
對於非 Java 體語言的 也有 Spring Cloud Sidecar 可以接入 Spring Cloud 架構, 對於 .NET 的應用 Pivotal 則是推出對應的組件 Steeltoe 可以無縫接入

再說 未來都是包成 Docker 跑在 Kubernetes 內了啊....
不過追蹤鏈路 跟 斷路器 這件事 Kubernetes 還沒有很好的組件開發出來
但有社群在做整合 Spring Cloud 到 Kubernetes 這件事 Spring Cloud Kubernetes

所以大致上不用擔心 Spring 或是 Spring Cloud 被棄坑或是淘汰吧XD
如果你現在就想使用 微服務架構 直接用 Spring Cloud 或是 你想上 Kubernetes 我覺得都是還不錯的選擇.


上一篇
Day 29 - 服務合約模擬器 Cloud Contract Stub Runner
下一篇
Day 31 - 客製化 Swagger UI
系列文
30天從零開始 使用 Spring Boot 跟 Spring Cloud 建構完整微服務架構35
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言