我的 Maven 项目依赖于通过 liquibase 通过另一个外部项目创建的数据库架构。 为了测试我的项目,我需要在我的机器上生成这个数据库结构。 有没有办法在我的项目的 pom 本身中指定 liquibase 项目详细信息(组 ID、 Artifact 、版本等以及必需的 liquibase 参数),以便在执行任何测试之前生成数据库结构。
P.S.:我知道如果该项目确实存在于我的机器中,我可以使用如下所示的内容:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>create-unitttest-db-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${skipSchemaCreation}</skip>
<executable>mvn</executable>
<arguments>
<argument>-f</argument>
<argument>../proj-liquibase-db/pom.xml</argument>
<argument>-P${proj.test.liquibase.create.profile},create</argument>
<argument>clean</argument>
<argument>install</argument>
<argument>-DdefaultSchemaName=${proj.test.schema.unittest}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
我想在此处指定 proj-liquibase-db
的项目坐标,而不是其 pom 文件的路径。
P.P.S:如果不可能,请告诉我并建议一些替代方案,因为我真的被困在这里了。
最佳答案
您可以使用依赖插件将包含 liquibase xml 文件的项目生成的 Artifact 解压到“目标”目录的子文件夹中。 目标应该是依赖:解包。 然后,您只需在测试类中配置 liquibase 即可加载这些文件。
亲切的问候
关于java - 如何从外部项目的pom执行maven liquibase pom?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59329879/