【发布时间】:2018-12-28 15:36:57
【问题描述】:
是否可以从 maven flyway 插件中的 jar 迁移?我对 sqls 和 java(编译为类)没有问题,但对 jars 没有成功。类路径设置正确。
【问题讨论】:
是否可以从 maven flyway 插件中的 jar 迁移?我对 sqls 和 java(编译为类)没有问题,但对 jars 没有成功。类路径设置正确。
【问题讨论】:
好的,我已经调试了源代码。 Jar 需要一个特殊的协议,当它被放置在 flyway 命令行工具的 /jars 目录中时,它会被提供给它。在 flyway maven 插件中没有这样的等价物。
【讨论】:
这是对从包含多个 flyway SQL 文件的 jar 工件文件执行 flyway-maven-plugin 的限制的轻微解决方法。
创建个人资料
这是我的示例配置文件
<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
【讨论】: