【发布时间】:2023-04-06 06:18:01
【问题描述】:
我的单元测试完全可以使用 Postgres,但是当我切换到 H2 时出现以下异常:
SchemaManagementException: Schema-validation: missing table [inspection]
这是我的 application.yaml 文件:
spring:
server:
port: 8080
datasource:
url: jdbc:h2:mem:testdb
driverClassName: org.h2.Driver
username: test
password: test
jpa:
hibernate:
#defaultSchema: public
dialect: org.hibernate.dialect.H2Dialect
hbm2ddlAuto: validate
showSql: true
jdbcBatchSize: 20
liquibase:
enabled: true
change-log: /db/changelog/changelog-master.xml
url: jdbc:h2:mem:testdb
user: test
password: test
# http://localhost:8080/h2-console
h2:
console:
enabled: true
根据记录器执行 liquibase 变更集,如果我切换回 Postgres,则单元测试可以很好地使用相同的变更集。
【问题讨论】: