为什么我的 Testcontainers 测试挂起直到 "Waiting for database connection to become available at" 超时?

Why does my Testcontainers test hang till timeout on "Waiting for database connection to become available at"?

当使用 Testcontainers 构建 JUnit 测试时,我的测试在消息 "Waiting for database connection to become available at" 和容器日志之后挂起直到超时,然后有用地显示,不会产生任何错误。我什至可以使用我最喜欢的 JDBC-query-tool.

连接到 运行 docker 容器

目前我正在使用 MySQL 容器。

这是因为我没有在类路径中包含 MySQL JDBC 驱动程序。 Testcontainers 没有记录 'SELECT 1' 的事实,它表明它正在做,因为缺少驱动程序而出错。通常它应该首先失败并超时,直到容器启动并-运行。但现在由于缺少驱动程序而失败,并且不知何故无法区分。