javaspring-bootspring-cloudamazon-sqsspring-cloud-aws

Which Spring Cloud AWS version should be used with Spring Boot 3?


I am trying to make SqsListener work but I can't with Spring Boot 3, it simply doesn't receive anything. When I change Spring Boot version back to 2.X everything's work perfectly. I am using 2.4.2 version of Spring cloud:

...
    <dependency>
            <groupId>io.awspring.cloud</groupId>
            <artifactId>spring-cloud-starter-aws-messaging</artifactId>
        </dependency>
</dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.awspring.cloud</groupId>
                <artifactId>spring-cloud-aws-dependencies</artifactId>
                <version>2.4.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

Can you please point me to the correct version of spring cloud? Would I need to use milestone version for that?


Solution

  • It doesn't work as version 2.4.2 of spring-cloud-starter-aws-messaging relies on spring.factories for Spring Boot autoconfiguration, but the support for that has been removed in Spring Boot 3.0.0. See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files.

    You can enable the auto configuration by creating the following file

    src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
    
    # content
    io.awspring.cloud.autoconfigure.messaging.SqsAutoConfiguration
    

    But, it probably won't work anyway as spring-cloud-aws also relies on classes from Spring Messaging that were deprecated and removed in Spring 6 (which is used in Spring Boot 3), specifically org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.

    You'll have to wait for Spring Cloud AWS to support Spring Boot 3. They are working on Spring Cloud AWS 3.0.0, but I don't think it has a release date yet. https://github.com/awspring/spring-cloud-aws