我想在每次测试执行之前启动一个新的 postgres docker 容器,而不是在运行所有集成测试之前启动一次。我目前拥有的配置就像大多数谷歌结果一样:
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
<configuration>
<imagePullPolicy>IfNotPresent</imagePullPolicy>
<images>
<image>
<alias>it-database</alias>
<name>postgres:11.3</name>
<run>
<namingStrategy>alias</namingStrategy>
<ports>
<port>5555:5432</port>
</ports>
<wait>
<log>(?s)database system is ready to accept connections.*database system is ready to accept connections
</log>
<time>20000</time>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker:start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker:stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>