当前位置: 首页 > 知识库问答 >
问题:

Testcontainers Quickstart示例不起作用?

颜高格
2023-03-14

我正在尝试JUnit5TestContainers快速启动示例:

<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);

}
The method parse(String) is undefined for the type DockerImageName

共有1个答案

祁霖
2023-03-14

对于testcontainer1.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")
 类似资料:
  • 问题内容: 我是Socket.IO的100%新手,并且刚刚安装了它。我试图遵循一些示例,并且可以使服务器端运行,但似乎无法使客户端连接。 以下是我的server.js: 这是我的index.html 当我执行node server.js时,它指示socket.io已启动。 当我加载index.html时,出现一行,指出“调试-服务静态/socket.io.js”,但除此之外,没有控制台消息或其他行

  • 问题内容: 我正在尝试运行JavaKinesisWordCountASL示例。 该示例似乎连接到我的Kinesis Stream并从该流中获取数据(如下面的日志所示)。但是,在示例中,Sparks不会调用传递给unionStreams.flatMap方法的调用函数,并且不会打印任何单词计数。 我尝试同时使用Java 8和Java 7运行。我正在ubuntu实例上运行它。相同的示例适用于我的Macb

  • 我已经按照说明实现了facebook android cognito示例cognitosyncdemo,在尝试同步数据集时出现以下错误, E/ListDatasetsActivity(8541):原因:com.amazonaws.AmazonServiceException:检测到1验证错误:“登录”处的值“{graph.facebook.com=}”无法满足约束:映射值必须满足约束:成员的长度必

  • 问题内容: 我正在尝试学习使用方法,但无法正常工作。这是文档中的代码 它应该输出 你好鲍勃 但是我得到了 没有错误或其他消息,它只是坐在那里,它从32位版本的python 2.7的Windows 7计算机上的已保存.py文件中运行 问题答案: 我的猜测是您正在使用IDLE尝试运行此脚本。不幸的是,此示例无法在IDLE中正确运行。请注意文档开头的注释: 注意:此软件包中的功能要求子 模块可以导入 主

  • 问题内容: 我正在从http://facebook.github.io/react/docs/tutorial.html编写React.js教程。这是我的文件: template.html: 和tut.js: 但是,当我在浏览器中打开它时,我只看到一个空白页面,没有任何评论。我究竟做错了什么? 问题答案: Chrome浏览器不允许您通过XHR 加载网址(如其他地方所述,这是浏览器内部转换的工作方式

  • 以下示例代码应加速Raku程序的执行: 我记得,它在一段时间前就起作用了,但现在我总是以4秒的运行时间结束。也使用。race()或添加参数不会改变任何事情。要同时运行两个进程,我必须做什么?