【发布时间】:2020-12-09 15:35:17
【问题描述】:
我正在尝试执行以下操作;
但使用 org.testcontainers.containers.MySQLR2DBCDatabaseContainer
谁能告诉我这是如何实现的,因为 MySQLR2DBCDatabaseContainer 似乎没有以下方法:
- ::getJdbcUrl
- ::getPassword
- ::获取用户名
@Testcontainers
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ApplicationIT {
@Container
public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer()
.withPassword("inmemory")
.withUsername("inmemory");
@DynamicPropertySource
static void postgresqlProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgreSQLContainer::getJdbcUrl);
registry.add("spring.datasource.password", postgreSQLContainer::getPassword);
registry.add("spring.datasource.username", postgreSQLContainer::getUsername);
}
@Test
public void contextLoads() {
}
}
【问题讨论】:
-
“通过 R2DBC URL 方案启动的数据库容器”对您有用吗? testcontainers.org/modules/databases/r2dbc
标签: java mysql testcontainers spring-data-r2dbc r2dbc