我有一个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