領先一步
VMware 提供培訓和認證,以加速您的進度。
了解更多以下是來自 Spring Cloud AWS 專案維護者的客座文章。
我很高興代表 Spring Cloud AWS 團隊和 Spring Cloud AWS 周圍的社群分享我們剛剛發布了 Spring Spring Cloud AWS 2.3 - 這個版本與 Spring Boot 2.4 和 Spring Cloud 2020.0 相容。
此版本包含與 Cognito 的新整合以及一系列小的改進、修復和變更,我們相信這些改進將使使用 Spring Cloud AWS 更加愉快。
我相信最令人驚訝的變化是,現在您需要在您的 pom.xml
檔案中包含一個單獨的 Spring Cloud AWS BOM
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-dependencies</artifactId>
<version>2.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
此外,dependencies group id 必須更新為 io.awspring.cloud
<dependencies>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws-messaging</artifactId>
</dependency>
</dependencies>
所有類別都已從 org.springfamework.cloud.aws
移至 io.awspring.cloud
套件。
按 Spring Cloud AWS 模組組織的最重要的變更
ClientConfiguration
初始化 AWS 用戶端時使用的 ClientConfiguration
現在可以透過建立名為 "com.amazonaws.ClientConfiguration.BEAN_NAME" 的 bean 來定義。
也可以透過定義類型為 ClientConfiguration
且名稱特定於整合的 bean 來為特定整合提供 ClientConfiguration
- 例如,對於 SQS 用戶端,bean 名稱必須為 sqsClientConfiguration
。
您可以閱讀更多關於用戶端配置的資訊
為了改善不使用 EC2 執行個體資料的應用程式的啟動時間,預設會停用 ContextInstanceDataAutoConfiguration
。 若要啟用它,請將 cloud.aws.instance.data.enabled
設定為 true
。
AWS SDK 已升級至 1.11.951
對於每個整合的 AWS 服務,您可以設定 Spring Cloud AWS 透過設定組態屬性來使用自訂端點。 此範例示範如何執行此操作
cloud.aws.s3.endpoint=https://127.0.0.1:4566
cloud.aws.sqs.endpoint=https://127.0.0.1:4566
cloud.aws.rds.endpoint=https://127.0.0.1:4566
當您在整合測試中使用 Localstack 時,使用自訂端點特別有用。
XML 配置現在已棄用,將在下一個主要版本升級中移除。
除了全域區域配置之外,每個整合都可以靜態設定不同的區域。 閱讀更多關於配置區域的資訊。
@EnableXXX
註解@EnableXXX
註解已被棄用。 我們建議使用 Spring Boot 自動配置。
現在可以透過設定 enabled
屬性來啟用或停用每個服務。
預設情況下會使用 DefaultAWSCredentialsProvider
和 DefaultAWSRegionProviderChain
。 已捨棄 cloud.aws.credentials.use-default-aws-credentials-chain
和 cloud.aws.region.use-default-aws-region-chain
屬性。
為了簡化不使用 CloudFormation 支援的應用程式的專案設定,預設情況下會停用與 CloudFormation 相關的自動配置。 若要在 Spring Cloud AWS 中啟用 CloudFormation 支援,您必須新增以下相依性以觸發 ContextStackAutoConfiguration
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-cloudformation</artifactId>
</dependency>
SES 支援已從 context
模組提取到單獨的 spring-cloud-aws-ses
模組。 還有一個專用的啟動器:spring-cloud-aws-ses-starter
。
Spring Cloud AWS 提供了對 AWS Cognito 的基本支援,簡化了 OAuth2 的設定。請參閱Cognito 支援以了解更多資訊。
spring.config.import
載入屬性。請參閱將您的 Spring Cloud 應用程式與 AWS Parameter Store 整合以了解更多資訊。javax.validation:validation-api
的依賴。spring.config.import
載入屬性。請參閱將您的 Spring Cloud 應用程式與 AWS Secrets Manager 整合以了解更多資訊。javax.validation:validation-api
的依賴。SimpleMessageListenerContainer#isQueueRunning
方法現在對擴充類別可見。#350SqsListener
引數中對原生 SQS 訊息的支援。#295queueStopTimeout
可以透過 SimpleMessageListenerContainerFactory
進行設定。#504 #507SqsListener
中解析 SqsMessageHeaders
的支援。新增了 ApproximateFirstReceiveTimestamp
、ApproximateReceiveCount
和 SentTimestamp
標頭 #296ObjectMapper
執行個體,而不是建立自訂的 ObjectMapper
執行個體。#533、#522 和 #540SimpleStorageResource
在 S3 物件中繼資料上設定 content-type
屬性。#262
讓 RDS 執行個體名稱設定更有彈性。例如,對於名為 test
的執行個體,您現在必須設定以下項目,而不是設定 cloud.aws.rds.test.username=user
屬性
cloud.aws.rds.instances[0].db-instance-identifier=test
cloud.aws.rds.instances[0].username=user
移除了 spring-cloud-aws-actuator
模組。相反地,我們建議直接使用對 micrometer-registry-cloudwatch
的依賴。#571
在 2020 年 4 月 17 日,宣布 Spring Cloud GCP 和 Spring Cloud AWS 不再是 Spring Cloud 版本列車的一部分。不屬於版本列車也意味著從 Github 上的 Spring Cloud 組織移出,並因此具有新的 Maven 座標和套件名稱。
我們選擇 awspring 作為頂層名稱,並選擇 io.awspring.cloud
作為 Spring Cloud AWS 的頂層套件,這讓我們有機會建立其他與 Spring 相關和與 AWS 相關但不一定與 Spring Cloud 相關的套件。
在 Spencer Gibb 和 Spring 團隊其他成員的大力協助下,我們遷移到新的儲存庫,並為 Spring Cloud AWS 建立了一個新的家:https://github.com/awspring/spring-cloud-aws。
從現在開始,我們的努力將集中在基於 AWS SDK 2.0 的 3.0 版本上。此版本將有機會重新審視每個已實作的模組,並使其更好地與 Spring Boot 慣例對齊。
2.3.x 將收到錯誤修復,並開放社群貢獻,但我們(作為核心團隊)將不會專注於新增功能或模組。
作為 Hoxton 版本列車的一部分,2.2.x 將繼續在原始 Spring Cloud 儲存庫中維護。
Spring Cloud AWS 是一個社群專案,由核心團隊的 Maciej Walkowiak、Eddú Meléndez 和 Matej Nedic 負責。我們非常樂意接受社群的貢獻。在不久的將來,我們將更新貢獻指南並發布 Spring Cloud 3.0 的路線圖。
敬請關注。