liquibase脚本通过maven进行集成testing,在docker中运行

正如标题所说,我试图find一种方法来运行liquibase脚本,我们已经从maven的新鲜的mysql docker图像运行集成testing。

到目前为止,我只findmaven插件来运行我的docker容器,并且设法从我需要的其他项目中将liquibase xmls和sqls拖到当前的项目中。

<plugin> <groupId>org.jolokia</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.13.9</version> <configuration> <useColor>true</useColor> <verbose>true</verbose> <removeVolumes>true</removeVolumes> <images> <image> <name>mysql:5.7.9</name> <run> <env> <MYSQL_ROOT_PASSWORD>${mypassword}</MYSQL_ROOT_PASSWORD> </env> <ports> <port>3306:3306</port> </ports> <volumes> <bind> <volume> ${project.build.testOutputDirectory}/db-scripts:/tmp/import:ro </volume> </bind> </volumes> </run> </image> </images> </configuration> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> </execution> <execution> <id>stop</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> 

但是我仍然在努力寻找一种方法,在所有集成testing之前,如何将所有这些脚本应用到docker中运行的数据库上。

有人可以请你澄清一下这个问题。 谢谢

UPD:find了liquibase maven插件,但是仍然面临mysql docker镜像中liquibase更新模式的问题。 有一个错误:

 Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 

我的liquibase插件的设置:

  <plugin> <groupId>org.liquibase</groupId> <artifactId>liquibase-maven-plugin</artifactId> <version>3.2.2</version> <configuration> <changeLogFile>${path_to_changelog}/changelog.xml</changeLogFile> <driver>com.mysql.jdbc.Driver</driver> <url>jdbc:mysql://localhost:3306</url> <username>${mysql_username}</username> <password>${mysql_password}</password> <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase> <logging>debug</logging> </configuration> <executions> <execution> <phase>pre-integration-test</phase> <goals> <goal>update</goal> </goals> </execution> </executions> </plugin> 

Interesting Posts