您可以为具有不同配置的单个插件指定多个执行:
<plugin> <groupId>org.flywaydb</groupId> <artifactId>flyway-maven-plugin</artifactId> <version>3.0</version> <executions> <execution> <id>first-execution</id> <phase>compile</phase> <!--whatever phase you need--> <goals> <goal>migrate</goal> </goals> <configuration> <url>jdbc:mysql://localhost:3306/schema2</url> <user>root</user> <password>root</password> <locations> <location> filesystem:/path/to/migrations/folder </location> </locations> </configuration> </execution> <execution> <id>second-execution</id> <phase>compile</phase> <!--whatever phase you need--> <goals> <goal>migrate</goal> </goals> <configuration> <url>jdbc:mysql://localhost:3306/schema1</url> <user>root</user> <password>root</password> <locations> <location> filesystem:/path/to/other/migrations/folder </location> </locations> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version> </dependency> </dependencies></plugin>
您可以使用’location’属性来定义要为每个模式运行的迁移,就像在上面的示例中所做的一样。位置类型由其前缀确定。无前缀的位置或以classpath开头的位置:指向classpath上的包,并且可能包含基于sql和基于Java的迁移。以文件系统开头的位置:指向文件系统上的目录,并且只能包含sql迁移。



