在使用测试容器时,我无法找到我的资源映射,在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的资源在任何类加载器中都无法找到
项目结构
有同样问题的人吗?