Currently, spring-boot-testcontainers supports only org.testcontainers.containers.KafkaContainer, but not org.testcontainers.containers.KafkaContainer.

The former is for use of confluentinc/cp-kafka derived images, the later is for use of apache/kafka derived images.

It's a bit confusing to me why testcontainers chose this specific package structure and didn't introduce a common interface, but it's also confusing that only one variant is supported at the moment, since the documentations exclude the import paths.

Versions - org.testcontainers:kafka:1.20.1 - org.springframework.boot:spring-boot-testcontainers:3.3.1

Spring Dependency Management Plugin picks 1.19.8 by default. The issue is reproducible on that version as well.

I'd expect the following test to work

import org.testcontainers.kafka.KafkaContainer;

@SpringBootTest
@Testcontainers
class MyIntegrationTests {

    @Container
    @ServiceConnection
    static KafkaContainer kafkaContainer  = new KafkaContainer("apache/kafka:3.8.0");

    @Test
    void myTest() {
        // ...
    }

}

Currently I get

No ConnectionDetails found for source '@ServiceConnection source for MyIntegrationTests.kafkaContainer'
org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsNotFoundException: No ConnectionDetails found for source '@ServiceConnection source for MyIntegrationTests.kafkaContainer'

Exception context added for people to find this issue

Comment From: goatfryed

I'd prepare a PR, unless there was some explicit decision to exclude the kafka.KafkaContainer

Comment From: wilkinsona

Thanks for the suggestion and the offer of a PR but support was already added in Spring Boot 3.4.0-M1: https://github.com/spring-projects/spring-boot/pull/40695.