无法解析符号“QueueMessagingTemplate”

问题描述 投票:0回答:1

我目前正在使用 Spring Boot 2.7 开发库。在迁移到 Spring Boot 3.1.4 的过程中,我在一个类上遇到了错误,其中:

import org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate;

未找到。 尽管我的 jar 存在于类路径中,但仍然找不到该类。

我已经清除了缓存,刷新了gradle依赖

gradle 文件包含以下依赖项:

implementation(platform("org.springframework.cloud:spring-cloud-aws-dependencies:${property('spring-cloud-aws-dependencies.version')}"))

spring-cloud-aws-dependencies.version = 2.2.6.RELEASE
spring spring-boot spring-cloud spring-messaging
1个回答
0
投票

为了将 SDK 与 Spring Boot 3 一起使用,您应该更改为新的依赖项并迁移到新的消息传递方法:

 <!-- For SQS -->
 <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-aws-starter-sqs</artifactId>
 </dependency>

 <!-- For SNS -->
 <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-aws-starter-sns</artifactId>
 </dependency>

请注意,使用

spring-cloud-aws-messaging
依赖项并不能解决问题,因为它不是为 Spring Boot 3 设计的,而且在运行时您仍然可能会错过一些类。我假设您正在使用
QueueMessagingTemplate
发送至 SQS;如果是这样的话,您可以尝试
SqsTemplate
实现相同的

© www.soinside.com 2019 - 2024. All rights reserved.