SpringBoot - Spring Boot 2.3.0 M1發行說明


1、從Spring 2.2 進行升級所需要的注意事項

1、廢棄的一些類。

在SpringBoot 2.2中被廢棄的類、方法和屬性在這個版本中已經被刪除。在升級之前,請確保您沒有調用不推薦的方法

可以參考官方文檔
1、https://github.com/spring-projects/spring-boot/pull/19189
2、https://github.com/spring-projects/spring-boot/pull/19699


2、內置組件的版本最低要求升級

如果你使用Gradle,需要的最低版本是 5.6 以上
如果你使用Jetty 嵌入式容器,需要的最低版本是 9.4.22以上

3、Springcloud 相關

移除了 Spring Cloud Connectors starter 組件,並推薦使用 Java CFEnv 進行代替

4、驗證相關
spring-boot-starter-validation 模塊不再默認包含,如果需要使用者個模塊,需要在POM 文件中顯式的進行引用纔可以

5、ElasticSearch傳輸變化

原生Elasticearch傳輸在以前的SpringBoot版本中被廢棄,因爲Elasticearch和Spring數據本身在下一個版本中不支持它。此支持已在SpringBoot中刪除

具體詳情請參考Spring 官方文檔
https://github.com/spring-projects/spring-boot/issues/19668

另外,Elasticsearch現在提供了一個官方的HTTP客戶機,Spring數據作爲傳輸支持它。對Jest庫的支持已在SpringBoot2.2.0中被廢棄,並已從SpringBoot中刪除

參考:https://github.com/spring-projects/spring-boot/pull/19681

Spring Boot現在默認使用ElasticSearch 7.5+

6、Cassandra 升級

Spring Boot現在默認使用Cassandra 4.3+。這個新的驅動程序有一些破壞的變化,暫時Spring 團隊還是處理當中

如果你是依靠ClusterBuilderCustomizer若要自定義Cluster,這個概念在v4中不再存在,而是被兩個更具體的自定義器所取代:

DriverConfigLoaderBuilderCustomizer自定義驅動程序的屬性。請將其用於尚未公開的任何屬性。

CqlSessionBuilderCustomizer自定義CqlSession(前Session).

此外,卡桑德拉v4驅動器不再有自動的地方直流推論從接觸點。因此,必須使用默認的負載平衡策略來設置“本地數據中心”屬性,並且接觸點必須位於該數據中心。新的spring.data.cassandra.local-datacenter屬性以輕鬆設置本地數據中心。

最後,聯絡點現在以host:port。確保更新配置以指定每個接觸點要使用的端口

2、支持用雲本地構建包構建Docker映像

Support for building Docker images using Cloud Native Buildpacks has been added to the Maven and Gradle plugins via the spring-boot:build-image goal and the bootBuildImage task.

支持使用Native 的構建包構建docker 鏡像,他已經被加入到Maven 和Gradle 插件裏面

3、支持構建分層jar,以便於打包在docke的鏡像中

Maven和Gradle插件已經添加了對構建內容分離爲層的JAR文件的支持。分層根據JAR的更改頻率將其內容分隔開來。這種分離允許建立更高效的Docker 鏡像。未更改的現有層可與已更改的層放在頂部重用

分層JAR還爲通過新的JAR模式列出和提取其層提供了內置支持。要查看可用的選項,請使用-Djarmode=layertools,如以下示例所示

$ java -Djarmode=layertools -jar build/libs/layered-app-0.0.1-SNAPSHOT.jar 
Usage:
  java -Djarmode=layertools -jar layered-app-0.0.1-SNAPSHOT.jar

Available commands:
  list     List layers from the jar that can be extracted
  extract  Extracts layers from the jar for image creation
  help     Help about any command

4、現在已經支持了配置屬性的端到端的可跟蹤性質

/actuator/configprops端點提供有關配置屬性的端到端信息,將其行爲與環境端點對齊.例如,在添加server.server-header=Spring Boot在你的application.properties,端點將顯示以下內容:

"serverHeader": {
  "origin": "class path resource [application.properties]:2:22",
  "value": "Spring Boot"
},

具體的開業去參考一下官方的文檔
https://github.com/spring-projects/spring-boot/issues/17886

5、對大型Jar 包的友好支持

使用Maven和Gradle構建的FAT JAR現在包括一個索引文件,當jar 包越來越大的時候,這個索引文件用於確保類路徑的排序與直接執行JAR時相同。

6、進行了一系列的依賴升級

Spring Data Neumann

Spring HATEOAS 1.1

Spring Integration 5.3

Spring Kafka 2.4

Spring Security

7、更新了第三方的一些依賴,其中主要的需要關注的如下

AssertJ 3.14

Elasticsearch 7.5

Flyway 6.1

Hibernate Validator 6.1

Infinispan 10.1

Kafka 2.4

Mockito 3.2

8、對JPA 的變更

JPA 的一些配置的默認值改掉了,具體參考着2個地方的文檔

https://github.com/spring-projects/spring-boot/issues/16230

https://github.com/spring-projects/spring-boot/issues/16747

9、配置項的更改

這個spring.http.屬性已移動到server.servlet.encoding., spring.mvc.和spring.codec

詳細說明文檔:https://github.com/spring-projects/spring-boot/issues/18827

發佈了442 篇原創文章 · 獲贊 1379 · 訪問量 235萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章