spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

No ConnectionDetails found for source '@ServiceConnection source for Bean 'localStackContainer'

Open gregmagdits opened this issue 1 month ago • 0 comments

Type: Bug

Component: Testing

Describe the bug The @ServiceConnection annotation only seems to work for the deprecated org.testcontainers.containers.localstack.LocalStackContainer class and not its replacement org.testcontainers.localstack.LocalStackContainer class in v2 of LocalStack

see https://github.com/awspring/spring-cloud-aws/discussions/1500 Sample

package com.example.demo;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;

// works v.1.21.3 of localstatck
// import org.testcontainers.containers.localstack.LocalStackContainer;

// doesnt work, v. 2.0.2 of localstack
import org.testcontainers.localstack.LocalStackContainer;
import org.testcontainers.utility.DockerImageName;

@SpringBootTest
class DemoApplicationTests {
    @Test
    void contextLoads() {
    }

    @TestConfiguration
    static class TestConfig {

        @Bean
        @ServiceConnection
        public LocalStackContainer localStackContainer() {
            return new LocalStackContainer(DockerImageName.parse("localstack/localstack:4.10"));
        }
    }

}

gregmagdits avatar Nov 20 '25 17:11 gregmagdits