H2-Oracle-liquibase-org.h2.jdbc.JdbcSQLException:未找到表“ all_sequences”;

时间:2019-02-08 17:25:44

标签: java spring-boot liquibase

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

  

由于:org.h2.jdbc.JdbcSQLException:表“ all_sequences”不是   发现; 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

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

添加:

jpa:
  properties:
    hibernate:
      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: