【问题标题】:Flyway Found more than one migration with versionFlyway 发现多个版本的迁移
【发布时间】:2020-01-17 11:11:09
【问题描述】:

我有两个 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)

解决此错误的任何指针。

【问题讨论】:

    标签: java spring flyway


    【解决方案1】:

    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 等中。

    【讨论】:

      【解决方案2】:

      \target\classes\db\migration 目录中有 2 个相同的文件。删除其中一个并重新启动您的项目。

      如果出现任何问题,请删除您的目标文件夹并重新构建您的项目。

      【讨论】:

        猜你喜欢
        • 2018-05-25
        • 2015-06-18
        • 2019-05-04
        • 2015-03-10
        • 2018-02-28
        • 2013-03-06
        • 2019-04-28
        • 2018-04-06
        • 2016-09-12
        相关资源
        最近更新 更多