Spring Cloud AWS 2.3 现已发布

发布 | Spencer Gibb | 2021年3月17日 | ...

以下是 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>

此外,依赖项的组 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

ClientConfiguration(在初始化 AWS 客户端时使用)现在可以通过创建一个名为 "com.amazonaws.ClientConfiguration.BEAN_NAME" 的 bean 来定义。

也可以通过定义一个类型为 ClientConfiguration 且名称特定于集成的 bean 来为特定集成提供 ClientConfiguration——例如,对于 SQS 客户端,bean 名称必须是 sqsClientConfiguration

您可以 在此处 阅读更多关于客户端配置的信息。

加快启动时间

为了提高不使用 EC2 实例数据的应用程序的启动时间,ContextInstanceDataAutoConfiguration 默认是禁用的。要启用它,请将 cloud.aws.instance.data.enabled 设置为 true

AWS SDK 版本升级

AWS SDK 已升级到 1.11.951。

为每个集成配置端点

对于每个集成的 AWS 服务,您可以通过设置配置属性来配置 Spring Cloud AWS 使用自定义端点。本示例展示了如何做到这一点。

cloud.aws.s3.endpoint=https://:4566
cloud.aws.sqs.endpoint=https://:4566
cloud.aws.rds.endpoint=https://:4566

在使用 Localstack 进行集成测试时,使用自定义端点特别有用。

弃用 XML 配置

XML 配置现已弃用,将在下一个主要版本升级中移除。

为每个集成配置区域

除了全局区域配置外,每个集成还可以静态设置不同的区域。 在此处 阅读更多关于配置区域的信息。

弃用 @EnableXXX 注解

@EnableXXX 注解已弃用。我们建议使用 Spring Boot 自动配置。

简化禁用集成

现在可以通过设置 enabled 属性来启用或禁用每个服务。

简化 SDK 配置

现在默认使用 DefaultAWSCredentialsProviderDefaultAWSRegionProviderChaincloud.aws.credentials.use-default-aws-credentials-chaincloud.aws.region.use-default-aws-region-chain 属性已被删除。

CloudFormation

为了简化不支持 CloudFormation 的应用程序的项目设置,CloudFormation 相关的自动配置默认是禁用的。要在 Spring Cloud AWS 中启用 CloudFormation 支持,您必须添加以下依赖项来触发 ContextStackAutoConfiguration

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-cloudformation</artifactId>
</dependency>

SES

SES 支持已从 context 模块提取到单独的 spring-cloud-aws-ses 模块。还有一个专用的启动器:spring-cloud-aws-ses-starter

Cognito

Spring Cloud AWS 提供了对 AWS Cognito 的基本支持,简化了 OAuth2 的配置。 在此处 阅读更多关于 Cognito 支持的信息。

Parameter Store

  1. 支持通过 Spring Cloud 2020.0 中引入的 spring.config.import 加载属性。 在此处 阅读更多关于将 Spring Cloud 应用程序与 AWS 参数存储集成的信息。
  2. 已删除 javax.validation:validation-api 的依赖。

Secrets Manager

  1. 支持通过 Spring Cloud 2020.0 中引入的 spring.config.import 加载属性。 在此处 阅读更多关于将 Spring Cloud 应用程序与 AWS Secrets Manager 集成的信息。
  2. 移除了自动配置模块 #526 的依赖。
  3. 已删除 javax.validation:validation-api 的依赖。
  4. 允许 Secrets Manager 前缀不带 "/" #736

SQS

  1. SimpleMessageListenerContainer#isQueueRunning 方法现在对扩展类可见。#350
  2. 增加了对 SQS 自定义数据类型的支持。#410
  3. SqsListener 参数中增加了对原生 SQS 消息的支持。#295
  4. 增加了消息删除策略的全局配置。#188
  5. 通过将队列停止时间增加到 20 秒来修复队列监听器的优雅关闭。queueStopTimeout 可以通过 SimpleMessageListenerContainerFactory 配置。#504 #507
  6. 在 SQS 消息属性中增加了对原始类型和无特定数据类型的支持。#221#374
  7. SqsListener 中增加了对解析 SqsMessageHeaders 的支持。增加了 ApproximateFirstReceiveTimestampApproximateReceiveCountSentTimestamp 标头 #296
  8. SQS 监听器默认使用应用程序上下文中存在的 ObjectMapper 实例,而不是创建自定义实例。#533#522#540
  9. 增加了对 SQS FIFO 队列的支持 #40

S3

SimpleStorageResource 在 S3 对象元数据中设置了 content-type 属性。#262

SNS

  1. @NotificationMessageMapping 现在可以正确处理特殊字符。#645
  2. 支持 String Array SNS messageAttributeDataType#368

RDS

使 RDS 实例名称配置更加灵活。例如,对于名为 test 的实例,您现在必须设置

cloud.aws.rds.instances[0].db-instance-identifier=test
cloud.aws.rds.instances[0].username=user

#495

CloudWatch

移除了 spring-cloud-aws-actuator 模块。我们建议直接使用 micrometer-registry-cloudwatch 的依赖。#571

为什么包名更改了?

2020 年 4 月 17 日,宣布 Spring Cloud GCP 和 Spring Cloud AWS 不再是 Spring Cloud Release Train 的一部分。不再是 Release Train 的一部分也意味着从 Github 上的 Spring Cloud 组织迁移,因此,需要新的 Maven 坐标和包名。

我们选择了 **awspring** 作为 Spring Cloud AWS 的顶级名称,io.awspring.cloud 作为顶级包,这样我们就可以创建其他与 Spring 相关但可能与 Spring Cloud 无关的包。

在 Spencer Gibb 和 Spring 团队其他成员的大力帮助下,我们迁移到了新的存储库,并为 Spring Cloud AWS 创建了一个新家:https://github.com/awspring/spring-cloud-aws

Spring Cloud AWS 的未来是什么?

从现在开始,我们的工作重点是 3.0 版本——基于 AWS SDK 2.0。此版本将有机会重新审视每个已实现的模块,并使其更好地符合 Spring Boot 的约定。

2.3.x 版本将接收错误修复,并将对社区贡献开放,但我们——作为核心团队——将不会专注于添加新功能或模块。

2.2.x 版本作为 Hoxton Release Train 的一部分,将继续在 原始 Spring Cloud 存储库中维护。

谁在负责 Spring Cloud AWS?

Spring Cloud AWS 是一个社区项目,核心团队成员包括 Maciej Walkowiak、Eddú Meléndez 和 Matej Nedic。我们非常乐意接受社区的贡献。在不久的将来,我们将更新贡献指南并发布 Spring Cloud 3.0 的路线图。

敬请关注。

获取 Spring 新闻通讯

通过 Spring 新闻通讯保持联系

订阅

领先一步

VMware 提供培训和认证,助您加速进步。

了解更多

获得支持

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件,只需一份简单的订阅。

了解更多

即将举行的活动

查看 Spring 社区所有即将举行的活动。

查看所有