【问题标题】:H2 - Oracle - liquibase - org.h2.jdbc.JdbcSQLException: Table "all_sequences" not found;H2 - Oracle - liquibase - org.h2.jdbc.JdbcSQLException:找不到表“all_sequences”;
【发布时间】:2019-02-08 17:25:43
【问题描述】:

我尝试将用于测试目的的 H2 添加到 Spring Boot application-test.yml,我的生产数据库是 Oracle。我想通过 liquibase 填充 H2 架构,但收到以下错误:

原因:org.h2.jdbc.JdbcSQLException: Table "all_sequences" not 成立; SQL语句:

我的配置如下:

spring:
  profiles:
    active: test
  datasource:
    url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=Oracle
    username: sa
    password:
    platform: h2
    driver-class-name: org.h2.Driver

  jpa:
    hibernate:
      ddl-auto: none
    generate-ddl: true

  h2:
    console:
      enabled: true
      path: /console

liquibase:
  url: ${spring.datasource.url}
  enabled: true
  user: sa
  password:
  change-log: classpath:liquibase/test-master.xml
  drop-first: true

如何调整上面的配置,我花了几个小时,但不知道如何使它工作。

【问题讨论】:

    标签: java spring-boot liquibase


    【解决方案1】:

    添加:

    jpa:
      properties:
        hibernate:
          dialect: org.hibernate.dialect.H2Dialect
    

    问题已解决。

    完整配置:

    spring:
      datasource:
        url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=Oracle
        username: sa
        password:
        platform: h2
        driver-class-name: org.h2.Driver
      jpa:
        properties:
          hibernate:
            dialect: org.hibernate.dialect.H2Dialect
        hibernate:
          ddl-auto: none
        generate-ddl: true
    
    liquibase:
      url: ${spring.datasource.url}
      contexts: test
      change-log: classpath:liquibase/test-master.xml
      user: sa
      password:
    

    【讨论】:

      【解决方案2】:

      all_sequences 是 Oracle 特定的数据库表。您应该只迁移用户定义的表。

      【讨论】:

      • 您能否给出一些提示,如何实现?
      猜你喜欢
      • 2022-06-22
      • 2020-04-23
      • 2013-05-24
      • 1970-01-01
      • 2017-12-10
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 2016-12-06
      相关资源
      最近更新 更多