Flyway发现了多个版本的迁移

时间:2019-09-16 15:14:03

标签: java spring flyway

我有两个sql文件,一个用于oracle,一个用于mySql数据库。路径如下

  db/migration/mysql/V1_1_migration.sql
  db/migration/oracle/V1_1_migration.sql

在运行测试时,出现错误

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found more than one migration with version 1.1
Offenders:
-> C:\code\service\db-repository\target\classes\db\migration\oracle\V1_1__migration.sql (SQL)
-> C:\code\service\db-repository\target\classes\db\migration\mysql\V1_1__migration.sql (SQL)

任何指针可以解决此错误。

1 个答案:

答案 0 :(得分:0)

Flyway位置属性需要一个{vendor}占位符,然后从数据库驱动程序ID(h2,mysql,oracle等)的小写字母开始,Spring Boot will work out the directory,例如:

spring.flyway.locations=db/migration,db/migration/{vendor}

在上面的示例中,与供应商无关的脚本可以进入db/migration,而与供应商特定的脚本可以进入db/migration/oracle等。