Tag: 飞桥

运行使用Flywaytesting并在Docker容器中embeddedPostgresql时的java.net.ConnectException

为了正确地testing我的Spring Boot应用程序,我在集成testing中使用了embedded式Postgresql 。 此外,我也使用Flywayconfiguration为使用基于Postgresqlconfiguration的数据源(查看EmbeddedPostgresConfiguration和FlywayConfiguration类)。 在我的环境(OS X)上运行时,所有的testing都没有问题,但在Docker容器(对于java:8和openjdk:8图像)中运行时失败。 我不知道是什么原因造成这种差异,以及如何解决这个问题,以便在Docker中传递testing(这是进一步的持续集成pipe道所需要的)。 这里是最小的代码示例来复制问题: https : //github.com/nkoder/postgresql-embedded-example 。 运行testing没有问题运行./gradlew clean test 。 以失败运行testing运行docker build . 。 在Docker内运行testing期间抛出的错误: java.lang.IllegalStateException Caused by: org.springframework.beans.factory.BeanCreationException Caused by: org.springframework.beans.BeanInstantiationException Caused by: org.flywaydb.core.api.FlywayException Caused by: org.postgresql.util.PSQLException Caused by: java.net.ConnectException 我试图为自己解决这个问题,但我仍然只有一些猜测,没有什么可靠的。 唯一的“提示”:对于embedded式Postgresqlconfiguration中使用的硬编码(非随机)端口,有时类似的exception发生在flyway.clean(); 在FlywayConfiguration类(从IntelliJ IDEA在更多的testing中运行实际项目的testing时),这似乎是通过提供的数据源访问数据库的第一行代码。 更新1: Postgresql实例在同一个Docker容器内的随机打开的端口上的本地主机上的testing期间被创build。 我怀疑没有必要连接到主机(外部容器)。

docker-compose中无法将docker Spring-Boot应用程序与mysql容器和flyway连接起来

我有一个连接到MySQL的一点春季启动服务。 当我使用maven和docker容器运行应用程序时,应用程序设置工作正常。 现在我想用Docker运行应用程序,所以我使用docker-compose来引导mysql和我的服务作为容器。 但是我不工作,我的服务无法连接到mysql,出现以下exception: accountservice_1 | 2015-11-18 08:55:11.626 ERROR 1 — [ main] oatomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool. accountservice_1 | com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure accountservice_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. accountservice_1 | at […]