从flyway maven插件的jar中迁移

问题描述 投票:1回答:2

是否有可能从Maven flyway插件的jar中迁移?我在使用sqls和java(编译为类)时没有问题,但是在jars上没有成功。类路径设置正确。

maven jar flyway
2个回答
0
投票

确定,我已经调试了源代码。将jar放在flyway命令行工具中的/ jars目录中时,需要向其提供特殊的协议。 flyway maven插件中没有这样的等效项。


0
投票

这是对从包含多个flyway SQL文件的jar工件文件中执行flyway-maven-plugin的限制的一个小变通方法。

创建个人资料

  1. 使用'maven-dependency-plugin:unpack'将jar文件的内容分解到特定目录。
  2. 运行'flyway-maven-plugin',其'位置'仅限于提取的目录。
  3. 不是很漂亮,但是可以。

这是我的样本资料

<profiles>
    <profile>
        <id>flyway</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.1</version>
                    <executions>
                        <execution>
                            <id>copy</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.abc</groupId>
                                <artifactId>flyway</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <type>jar</type>
                                <overWrite>true</overWrite>
                                <outputDirectory>${project.build.directory}/jars</outputDirectory>
                                <destFileName>my-flyway.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>true</overWriteSnapshots>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.flywaydb</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <version>${flyway.version}</version>
                    <configuration>
                        <sqlMigrationSeparator>__</sqlMigrationSeparator>
                        <locations>
                            <location>filesystem:./target/jars/my-flyway.jar</location>
                        </locations>
                        <url>${flyway.url}</url>
                        <user>${flyway.user}</user>
                        <password>${flyway.password}</password>
                        <schemas>
                            <schema>my_schema</schema>
                        </schemas>
                        <baselineOnMigrate>true</baselineOnMigrate>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.postgresql</groupId>
                            <artifactId>postgresql</artifactId>
                            <version>${postgresql.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

然后是maven命令行

mvn -P flyway clean process-resources flyway:migrate 
© www.soinside.com 2019 - 2024. All rights reserved.