在服务器和单元测试中使用liquibase迁移文件

我有一个Spring Boot项目,该项目使用postgreSQL作为数据库管理系统,并希望使用H2作为单元测试的数据源。

问题是:我想使用与服务数据库相同的liquibase迁移来创建h2实例的初始架构,然后避免通过主要资源和测试资源文件夹复制xml。

我该怎么做?

服务器application.properties

## PostgreSQL
spring.datasource.url=jdbc:postgresql://localhost:5432/database
spring.datasource.username=user
spring.datasource.password=pass

# Liquibase settings
spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml
logging.level.liquibase = INFO

测试application.properties

# H2
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:~/test_db;MODE=PostgreSQL
spring.datasource.username=user
spring.datasource.password=pass

# Liquibase settings
spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml
logging.level.liquibase = INFO
zhuxiwangzhenliang 回答:在服务器和单元测试中使用liquibase迁移文件

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3144892.html

大家都在问