测试无法编译,出现错误Cannot resolve method 'parse' in 'DockerImageName'

@SpringBootTest
@Testcontainers
public class KafkaContainerTest {
    @ClassRule
    public static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:5.2.1"));

    @Test
    public void testUsage() throws Exception {
            kafka.start();
            testKafkaFunctionality(kafka.getBootstrapServers());
    }
//...
}
build.gradle
plugins {
    id 'org.springframework.boot' version '2.3.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '2.3.4.RELEASE'
    implementation 'org.apache.kafka:kafka-streams'
    implementation 'org.springframework.kafka:spring-kafka'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.projectlombok:lombok'
    testCompile 'org.projectlombok:lombok'
    testCompile group: 'io.projectreactor', name: 'reactor-test', version: '3.3.10.RELEASE'
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.kafka:spring-kafka-test'
    testImplementation 'com.google.guava:guava:23.0'
    testImplementation 'org.testcontainers:testcontainers:1.14.3'
    testImplementation "org.testcontainers:junit-jupiter:1.14.3"
    testImplementation 'org.testcontainers:kafka:1.14.3'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}
在IntelliJ中导航到DockerImageName类时,显示Library source does not match the bytecode for class DockerImageNameThis answer没有帮助。
更新
这有效
testImplementation 'org.testcontainers:testcontainers:1.15.0-rc2'
testImplementation "org.testcontainers:junit-jupiter:1.15.0-rc2"
testImplementation 'org.testcontainers:kafka:1.15.0-rc2'

最佳答案

静态parse方法仅在七月份才添加到testcontainers库中。您正在使用1.14.3版本,该版本已于5月发布。我希望如果您将库的版本升级到15.X(版本1.15.0-rc2似乎是最新的),我希望您的问题将得到解决。
或者,您可以将该库的用法更改为1.14.3版本中的功能。
更新:我刚刚看到(并最终理解)@tgdavies的建议,您可以直接通过以下方式调用DockerImageName对象的构造函数:

return new DockerImageName(fullImageName);

09-30 09:53