是否可以从Maven flyway插件的jar中迁移?我在使用sqls和java(编译为类)时没有问题,但是在jars上没有成功。类路径设置正确。
答案 0 :(得分:0)
好的,我已经调试了源代码。当将jar放在flyway命令行工具中的/ jars目录中时,它需要提供一个特殊的协议。 flyway maven插件中没有这样的等效项。
答案 1 :(得分:0)
这是对从包含多个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