SpringBoot与Flyway版本问题

本文介绍了一个关于在Spring Boot项目中使用Flyway进行数据库迁移时出现的版本冲突问题,并提供了具体的错误信息及解决方案。建议将Flyway版本从8.0.5降级到5.2.1以确保兼容性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

记录今天在Spring boot项目中使用Flyway时遇到的版本冲突问题

1. 报错信息

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:65)

The following method did not exist:org.flywaydb.core.Flyway.migrate()

The method's class, org.flywaydb.core.Flyway, is available from the following locations:jar:file:/F:/Maven/LocalWarehouse/org/flywaydb/flyway-core/8.0.5/flyway-core-8.0.5.jar!/org/flywaydb/core/Flyway.class

It was loaded from the following location:file:/F:/Maven/LocalWarehouse/org/flywaydb/flyway-core/8.0.5/flyway-core-8.0.5.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.flywaydb.core.Flyway

2. 查看当前spring boot和flyway的版本

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
              <version>2.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>8.0.5</version>
        </dependency>

3.解决方法

将flyway版本降级至5.2.1即可

4.总结

springboot2.x
pom文件

<dependency>
   <groupId>org.flywaydb</groupId>
   <artifactId>flyway-core</artifactId>
   <version>5.2.1</version>
</dependency>

配置文件

# 配置flyway
spring.flyway.baseline-on-migrate=true
spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration
spring.flyway.table=flyway_schema_history

springboot1.x
pom

<dependency>
   <groupId>org.flywaydb</groupId>
   <artifactId>flyway-core</artifactId>
   <version>4.2.0</version>

配置文件 (注意spring boot1.x 配置使用flyway开头)

# 配置flyway
flyway.baseline-on-migrate=true
flyway.enabled=true
flyway.locations=classpath:db/migration
flyway.table=flyway_schema_history
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值