我有两个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)
解决此错误的任何指示。
Flywaylocations属性需要一个
{vendor}
占位符,然后Spring Boot将从数据库驱动程序id(h2,mysql,oracle等)的小写中计算出目录,例如:
spring.flyway.locations=db/migration,db/migration/{vendor}
在上面的示例中,与供应商无关的脚本可以放入
db/migration
中,而供应商特定的脚本可以放入 db/migration/oracle
等中。
arg中有2个相同的文件