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>

此外,依赖项的 group id 必须更新为 io.awspring.cloud

<dependencies>
    <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-starter-aws-messaging</artifactId>
    </dependency>
</dependencies>

所有类已从 org.springframework.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 版本升级

AWS SDK 已升级到 1.11.951

为每个集成配置端点

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

cloud.aws.s3.endpoint=http://localhost:4566
cloud.aws.sqs.endpoint=http://localhost:4566
cloud.aws.rds.endpoint=http://localhost: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 模块。还有一个专门的 starter: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 Parameter Store 集成的信息。
  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. 支持字符串数组 SNS messageAttributeDataType#368

RDS

使 RDS 实例名称配置更灵活。例如,对于名为 test 的实例,您现在必须设置而不是设置 cloud.aws.rds.test.username=user 属性。

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 发布列车的一部分。不再是发布列车的一部分也意味着从 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

Spring Cloud AWS 的未来如何?

从现在起,我们的工作重心将放在基于 AWS SDK 2.0 的 3.0 版本上。此版本将是一个重新审视每个已实现模块并使其更好地与 Spring Boot 约定对齐的机会。

2.3.x 版本将接收 bug 修复,并对社区贡献开放,但我们作为核心团队将不再专注于添加新特性或模块。

作为 Hoxton 发布列车的一部分,2.2.x 版本将继续在原始的 Spring Cloud 仓库中维护。

谁是 Spring Cloud AWS 的幕后推手?

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

敬请关注。

获取 Spring 时事通讯

订阅 Spring 时事通讯保持联系

订阅

领先一步

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

了解更多

获取支持

Tanzu Spring 在一份简单的订阅中提供了对 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

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

查看全部