3

在我的 Maven 项目中,我有多个 Maven 配置文件。在每个配置文件中,我都有docker-maven-pluginmaven-failsafe-plugin。这就是我设定目标和阶段的方式。

docker-maven-插件

<phase>pre-integration-test</phase>
<goals>
   <goal>start</goal>
</goals>

<phase>post-integration-test</phase>
<goals>
   <goal>stop</goal>
   <goal>remove</goal>
</goals>

maven-failsafe-插件

<phase>integration-test</phase>
<goals>
   <goal>integration-test</goal>
</goals>

<phase>verify</phase>
<goals>
   <goal>verify</goal>
</goals>

我有每种数据库类型的配置文件(即 MySQL、Postgres 等)。我想要做的是在 docker 上使用每种数据库类型运行我的集成测试。

我的问题是,我可以使用多个配置文件(即mvn clean install -P local-postgres,local-mysql)运行 mvn,以便每个配置文件一个接一个地执行吗?我的要求是不要一次有 2 个 docker 容器。

我观察到的是pre-integration-test所有配置文件的阶段首先运行,并以The name "/apim-postgres" is already in use by container xxxxx. 当给出多个配置文件时,maven 阶段应该如何工作?

有没有办法满足我的要求?

4

1 回答 1

0

我不确定这是否可行,但如果您独立定义每个配置文件,它应该可以工作。您定义每个插件两次,每个配置文件一个。执行顺序取决于各种因素。我不知道你在哪里定义了配置文件,但是如果它们是在同一个 pom 中定义的,那么顺序应该是在那个 pom.xml 中定义的。有关更多帮助,请参阅https://www.waltercedric.com/index.php?option=com_content&view=article&id=1795&catid=129&Itemid=332

于 2016-12-19T10:48:20.820 回答