Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从外部项目执行maven liquibase pom';是波姆吗?_Java_Maven_Liquibase - Fatal编程技术网

Java 如何从外部项目执行maven liquibase pom';是波姆吗?

Java 如何从外部项目执行maven liquibase pom';是波姆吗?,java,maven,liquibase,Java,Maven,Liquibase,我的maven项目依赖于通过liquibase通过另一个外部项目创建的数据库模式。 为了测试我的项目,我需要在我的机器上生成这个数据库结构。 是否有办法在我的项目的pom中指定liquibase项目细节(组id、工件、版本等以及必要的liquibase参数),以便在执行任何测试之前生成db结构 p.S.:我知道,如果我的机器中确实存在项目,我可以使用如下内容: <plugins> <plugin> <groupId>org.codeha

我的maven项目依赖于通过liquibase通过另一个外部项目创建的数据库模式。 为了测试我的项目,我需要在我的机器上生成这个数据库结构。 是否有办法在我的项目的pom中指定liquibase项目细节(组id、工件、版本等以及必要的liquibase参数),以便在执行任何测试之前生成db结构

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>

org.codehaus.mojo
execmaven插件
1.1
创建UnitTest数据库模式
过程测试资源
执行官
${skipSchemaCreation}
mvn
-f
../proj liquibase db/pom.xml
-P${proj.test.liquibase.create.profile},创建
清洁的
安装
-DdefaultSchemaName=${proj.test.schema.unittest}
我想在这里指定
项目liquibase db
的项目坐标,而不是其pom文件的路径


p.p.S:如果不可能,那么请让我知道并建议一些替代方案,因为我真的被困在这里。

您可以使用依赖插件将包含liquibase xml文件的项目生成的工件解包到“目标”目录的子文件夹中。 目标应该是依赖关系:解包。 然后,您只需在测试类中配置liquibase即可加载这些文件


亲切问候

而不是依赖关系:unpack,您应该通过在类路径中添加项目jar并提供其他必要参数(如db details等)来执行liquibase jar。

如果项目是用Maven管理的,您应该使用它来设置执行测试所需的所有内容。使用我建议的方法,您可以将解包绑定到maven生命周期的流程资源阶段。因此,Maven将在进入测试阶段之前注意使liquibase文件可用。然后您只需要配置测试上下文来执行liquibase。您不需要任何手动操作,所有操作都将由maven管理,并与测试的源代码一起存储在SCM存储库中。