You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpringBoot集成Flyway连接Oracle 19.21提示不支持Oracle 19.0问题求助

SpringBoot集成Flyway与Oracle 19.21时遇到数据库版本不支持问题

环境版本信息

flyway-core: 10.11.0
flyway-database-oracle: 10.11.0
spring-boot: 3.2.4
ojdbc11: 23.3.0.23.09

错误现象

启动应用时抛出异常:

Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception with message: Unsupported Database: Oracle 19.0

完整堆栈跟踪:

{"level":"ERROR","message":"Application run failed","timestamp":"2024-04-22T07:16:15.197+0200",
"logger":"o.s.boot.SpringApplication","context":"abc.service","throwable_class":"BeanCreationException","throwable_root_cause_class":
"FlywayException","stack_hash":"345a5cc5","stack_trace":"o.f.c.a.FlywayException: Unsupported Database: Oracle 19.0\n\tat 
o.f.c.i.d.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:105)\n\tat 
o.f.c.a.c.ClassicConfiguration.setDataSource(ClassicConfiguration.java:1095)\n\tat o.f.c.a.c.FluentConfiguration.dataSource(FluentConfiguration.java:624)\n\tat 
o.s.b.a.f.FlywayAutoConfiguration$FlywayConfiguration.configureDataSource(FlywayAutoConfiguration.java:185)\n\tat 
o.s.b.a.f.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:172)\n\tat 
j.i.r.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)\n\tat 
j.i.r.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)\n\tat 
j.i.r.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat 
j.l.reflect.Method.invoke(Method.java:568)\n\tat 
o.s.b.f.s.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)\n\t... 29 common frames omitted\nWrapped by: 
o.s.b.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' 
threw exception with message: Unsupported Database: Oracle 19.0\n\tat 
o.s.b.f.s.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)\n\tat 
o.s.b.f.s.ConstructorResolver.instantiate(ConstructorResolver.java:644)\n\t... 28 common frames omitted\nWrapped by: o.s.b.f.BeanCreationException: 
Error creating bean with name 'flyway' defined in class path resource 
            
[org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: 
Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception with message: 
Unsupported Database: Oracle 19.0\n\tat o.s.b.f.s.ConstructorResolver.instantiate(ConstructorResolver.java:648)\n\tat 
 o.s.b.f.s.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636)\n\tat 
 o.s.b.f.s.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1335)\n\tat 
o.s.b.f.s.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBe...\n"}

解决办法

  • 强制指定数据库类型:在SpringBoot配置文件中添加配置,跳过版本自动检测步骤,直接指定数据库类型为Oracle:

    # application.properties
    flyway.database-type=oracle
    

    或YAML格式:

    # application.yml
    flyway:
      database-type: oracle
    
  • 调整Flyway版本:如果强制指定类型后问题仍存在,可尝试降级Flyway到9.x系列(如9.22.3),该版本对Oracle 19c的版本识别逻辑兼容性更好。

  • 修正JDBC连接参数:在Oracle JDBC连接URL中添加版本兼容参数,确保驱动返回正确的版本信息:

    spring.datasource.url=jdbc:oracle:thin:@//你的主机地址:1521/你的服务名?oracle.jdbc.VersionCompatibility=19
    

内容的提问来源于stack exchange,提问作者Aarij Siddiqui

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 11:07:23