Maven 在相位上扩展飞行路线剖面

Maven 在相位上扩展飞行路线剖面,maven,flyway,Maven,Flyway,我试图使用flyway maven插件创建单独的概要文件,但阶段定义不能正常工作。这意味着,当我使用这两个配置文件时,我在执行时会出现错误,因为我猜使用“migrate database”中的配置“drop create database”,所以它失败了。有人知道如何修复它吗 <profiles> <profile> <id>drop-create</id> <build>

我试图使用flyway maven插件创建单独的概要文件,但阶段定义不能正常工作。这意味着,当我使用这两个配置文件时,我在执行时会出现错误,因为我猜使用“migrate database”中的配置“drop create database”,所以它失败了。有人知道如何修复它吗

    <profiles>
    <profile>
        <id>drop-create</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.flywaydb</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <driver>net.sourceforge.jtds.jdbc.Driver</driver>
                        <table>MIGRATION_LOG</table>
                        <sqlMigrationPrefix>EMP_</sqlMigrationPrefix>
                        <skip>false</skip>
                    </configuration>
                    <executions>
                        <execution>
                            <id>drop-create-database</id>
                            <!-- Need to garantee order of execution -->
                            <phase>package</phase>
                            <goals>
                                <goal>clean</goal>
                                <goal>migrate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>migrate</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.flywaydb</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <driver>net.sourceforge.jtds.jdbc.Driver</driver>
                        <table>MIGRATION_LOG</table>
                        <sqlMigrationPrefix>ALL_</sqlMigrationPrefix>
                        <skip>false</skip>
                    </configuration>
                    <executions>
                        <execution>
                            <id>migrate-database</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>migrate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

删除创建
org.flywaydb
FlywayMaven插件
3.1
net.sourceforge.jtds.jdbc.Driver
迁移日志
电磁脉冲_
假的
删除创建数据库
包裹
清洁的
迁移
迁移
org.flywaydb
FlywayMaven插件
3.1
net.sourceforge.jtds.jdbc.Driver
迁移日志
全部_
假的
迁移数据库
预集成测试
迁移

您必须指定每次执行的配置,而不是每个插件的配置。否则,同一插件的后续配置将覆盖以前的配置

这意味着您的pom.xml应该如下所示:

<profiles>
<profile>
    <id>drop-create</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.1</version>
                <executions>
                    <execution>
                        <id>drop-create-database</id>
                        <!-- Need to garantee order of execution -->
                        <phase>package</phase>
                        <goals>
                            <goal>clean</goal>
                            <goal>migrate</goal>
                        </goals>
                        <configuration>
                            <driver>net.sourceforge.jtds.jdbc.Driver</driver>
                            <table>MIGRATION_LOG</table>
                            <sqlMigrationPrefix>EMP_</sqlMigrationPrefix>
                            <skip>false</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>
<profile>
    <id>migrate</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.1</version>
                <executions>
                    <execution>
                        <id>migrate-database</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>migrate</goal>
                        </goals>
                        <configuration>
                            <driver>net.sourceforge.jtds.jdbc.Driver</driver>
                            <table>MIGRATION_LOG</table>
                            <sqlMigrationPrefix>ALL_</sqlMigrationPrefix>
                            <skip>false</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

删除创建
org.flywaydb
FlywayMaven插件
3.1
删除创建数据库
包裹
清洁的
迁移
net.sourceforge.jtds.jdbc.Driver
迁移日志
电磁脉冲_
假的
迁移
org.flywaydb
FlywayMaven插件
3.1
迁移数据库
预集成测试
迁移
net.sourceforge.jtds.jdbc.Driver
迁移日志
全部_
假的

两次执行的实际顺序是什么?对不起,我已经修改了描述。当我运行“clean package-Pdrop create,migrate”时,它用于从“migrate”而不是它自己的“drop create”配置。该死,我想我试过这个。。。显然我搞错了!非常感谢,很好用。