Testcontainers Quickstart Example 不起作用?
Testcontainers Quickstart Example does not work?
我正在尝试 Junit 5 Testcontainers 快速入门示例:
https://www.testcontainers.org/quickstart/junit_5_quickstart/
我对 jupiter 使用 5.6.1 版,对测试容器使用 1.14.3 版。
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
@Testcontainers
public class TestcontainersDemo {
@Container
public GenericContainer redis = new GenericContainer(DockerImageName.parse("redis:5.0.3-alpine"))
.withExposedPorts(6379);
}
Eclipse IDE 正在抱怨
The method parse(String) is undefined for the type DockerImageName
我该如何解决这个问题?
对于测试容器 1.14.3
只需使用。
@Container
public GenericContainer<?> redis = new GenericContainer<>("redis:5.0.3-alpine")
.withExposedPorts(6379);
或者切换到发布候选,例如版本1.15.0-rc2
,支持
DockerImageName.parse("redis:5.0.3-alpine")
我正在尝试 Junit 5 Testcontainers 快速入门示例:
https://www.testcontainers.org/quickstart/junit_5_quickstart/
我对 jupiter 使用 5.6.1 版,对测试容器使用 1.14.3 版。
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
@Testcontainers
public class TestcontainersDemo {
@Container
public GenericContainer redis = new GenericContainer(DockerImageName.parse("redis:5.0.3-alpine"))
.withExposedPorts(6379);
}
Eclipse IDE 正在抱怨
The method parse(String) is undefined for the type DockerImageName
我该如何解决这个问题?
对于测试容器 1.14.3
只需使用。
@Container
public GenericContainer<?> redis = new GenericContainer<>("redis:5.0.3-alpine")
.withExposedPorts(6379);
或者切换到发布候选,例如版本1.15.0-rc2
,支持
DockerImageName.parse("redis:5.0.3-alpine")