Liquibase 默认不支持达梦数据库,网上的教程改起来着实麻烦,索性就自己发布一个包来一劳永逸。
Maven 引入 liquibase 和 达梦JDBC驱动,额外引入 db-migration-dm 包:
<dependency>
<groupId>com.github.mengweijin</groupId>
<artifactId>db-migration-dm</artifactId>
<version>${db-migration-dm.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
db-migration-dm 版本说明(达梦)
db-migration-dm | spring boot | flyway | liquibase |
---|---|---|---|
✖ | spring boot 版本 < 2.6.2 | 版本 < 7.15.0 | 版本 < 4.5.0(未测试) |
1.1.6 | 版本 >= 7.15.0 ✔ | ||
1.1.6 | 2.6.x | 8.0.5 ✔ | 4.5.0(未测试) |
1.1.6 | 2.7.x | 8.5.13 ✔ | 4.9.1 ✔ |
1.1.6 | 3.0.x | 9.5.1 ✔ | 4.17.2 ✔ |
1.1.6 | 3.1.x | 9.16.3 ✔ | 4.20.0 ✔ |
开源代码 Gitee:https://gitee.com/mengweijin/db-migration
开源代码 Github:https://github.com/mengweijin/db-migration
然后按照 Liquibase 的使用方式直接使用即可。
注意: liquibase 中达梦数据库的 jdbc url 需要添加 compatibleMode=oracle 参数。
SpringBoot 参考配置:
spring:
datasource:
driver-class-name: dm.jdbc.driver.DmDriver
url: jdbc:dm://localhost:5236?compatibleMode=oracle
username: test
password: test123456
liquibase:
enabled: true
change-log: classpath:/db/changelog.xml
# 使用 flowable 时需要如下参考配置
flowable:
async-executor-activate: false
database-schema-update: true
database-schema: test
集成 flowable
maven 再增加引入 flowable 后,加上上面 spring boot 中有关于 flowable 的配置,直接启动应用程序即可自动创建 flowable 相关表。
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process</artifactId>
<version>${flowable.version}</version>
</dependency>
注意 flowable 版本。
flowable 6.8.0 版本,适配 springboot 2.x;
flowable 7.0.0 版本以及之后,适配 springboot 3.x;