作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 Test Containers 时找不到我的资源映射, 在 Postgres 版本中。我正在尝试类似的东西:
private static PostgreSQLContainer postgresqlContainer = new PostgreSQLContainer("postgres")
.withDatabaseName(DATABASE_NAME)
.withUsername(USER)
.withPassword(PASSWORD);
@ClassRule
@BeforeAll
public static void initContainer() {
postgresqlContainer.withExposedPorts(5432);
postgresqlContainer.withClasspathResourceMapping("../../../../../../../create.sh",
"/docker-entrypoint-initdb.d/00_create.sh",
BindMode.READ_ONLY);
postgresqlContainer.start();
}
但是,我找不到该文件。我什至尝试将脚本 create.sh 包含在同一目录中,但找不到:
java.lang.IllegalArgumentException: 路径为 ../../../../../../../create.sh 的资源在这些类加载器中找不到
项目结构
有人遇到同样的问题吗?
最佳答案
withClasspathResourceMapping
的用法是当您设置了类路径时。就我而言,我没有,而且这种方法不起作用。作为替换,我尝试使用 addFileSystemBind 并且工作得很好:
postgresqlContainer.addFileSystemBind(scriptsPath + File.separator + "create.sh",
"/docker-entrypoint-initdb.d/00_create.sh",
BindMode.READ_ONLY);
关于java - 找不到路径 PostgreSQLContainer testContainers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53480946/
我在使用 Test Containers 时找不到我的资源映射, 在 Postgres 版本中。我正在尝试类似的东西: private static PostgreSQLContainer
将我的容器创建为: public static PostgreSQLContainer container = new PostgreSQLContainer<>("postgres:latest")
我正在尝试使用 PostgreSQLContainer来自 测试容器 ( https://github.com/testcontainers/testcontainers-java + https:/
我是一名优秀的程序员,十分优秀!