flyway整合问题:java.lang.NoClassDefFoundError: org/flywaydb/core/api/configuration/FluentConfiguration

这个是我的原有依赖版本:

        <spring-boot.version>2.2.2.RELEASE</spring-boot.version>
        <flyway.version>5.0.3</flyway.version>

yaml配置:

spring:
  #flyway配置
  flyway:
    baseline-on-migrate: true
    #数据库连接配置
    url: ${spring.datasource.druid.url}
    user: ${spring.datasource.druid.username}
    password: ${spring.datasource.druid.password}
    #忽略脚本顺序
    out-of-order: true

异常信息:

Caused by: java.lang.NoClassDefFoundError: org/flywaydb/core/api/configuration/FluentConfiguration
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.getDeclaredMethods(Class.java:1975)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
	... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.flywaydb.core.api.configuration.FluentConfiguration
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	... 25 common frames omitted

到这里其实有点懵逼因为我以前用flyway是没有问题的,
以前的的maven依赖:

<!-- flyway-->
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>5.0.3</version>
        </dependency>
     <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
        <relativePath/>
    </parent>

yaml配置:

spring:
  #flyway配置
  flyway:
    baseline-on-migrate: true
    #数据库连接配置
    url: ${spring.datasource.url}
    user: ${spring.datasource.username}
    password: ${spring.datasource.password}
    #忽略脚本顺序
    out-of-order: true

但是我现在要用SpringBoot2.x版本不可能再用以前的配置,在网上找了一些资料,了解到这个问题引起的原因是因为springboot2.x对flyway的依赖为5.x,旧的api已经不支持,存在很多问题.大家可以看看这个SpringBoot的GIT网址里面有一些版本更新说明:
https://github.com/spring-projects/spring-boot/search?q=flyway&unscoped_q=flyway

解决方法跟换flyway依赖版本:

<dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>5.2.1</version>
 </dependency>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
*************************** APPLICATION FAILED TO START *************************** 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.FlywayAutoConfiguration$FlywayConfiguration.configureProperties(FlywayAutoConfiguration.java:255) The following method did not exist: 'org.flywaydb.core.api.configuration.FluentConfiguration org.flywaydb.core.api.configuration.FluentConfiguration.oracleSqlplus(boolean)' The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location: jar:file:/D:/repository/org/springframework/boot/spring-boot-autoconfigure/3.1.0/spring-boot-autoconfigure-3.1.0.jar!/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class The called method's class, org.flywaydb.core.api.configuration.FluentConfiguration, is available from the following locations: jar:file:/D:/repository/org/flywaydb/flyway-core/9.20.1/flyway-core-9.20.1.jar!/org/flywaydb/core/api/configuration/FluentConfiguration.class The called method's class hierarchy was loaded from the following locations: org.flywaydb.core.api.configuration.FluentConfiguration: file:/D:/repository/org/flywaydb/flyway-core/9.20.1/flyway-core-9.20.1.jar Action: Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration and org.flywaydb.core.api.configuration.FluentConfiguration Disconnected from the target VM, address: '127.0.0.1:52541', transport: 'socket' Process finished with exit code 1 怎么回事
07-22
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值