近期公司的项目在做国产化兼容,数据库方面试了下国产达梦数据库,踩了不少坑。。
项目使用SpringBoot 2.1.3.RELEASE +Mybatis 3.1.0,工作流使用Flowable 6.4.1,连接池使用Druid
配置文件
pom.xml中引入驱动jar包(可在达梦安装目录中找到)
com.dm DmJdbcDriver18 1.8
#nacos替换达梦
spring.datasource.driver-class-name=dm.jdbc.driver.DmDriver spring.datasource.url=jdbc:dm://127.0.0.1:5236/SYSDBA spring.datasource.username=SYSDBA spring.datasource.password=123456789
#达梦数据库不支持此项
#spring.datasource.druid.filters=stat,wall
#pagehelper使用mysql语法
pagehelper.helper-dialect=mysql
#mybatis设置database-id
mybatis.configuration.database-id=dm
#达梦数据库关闭flowable自动更新数据库结构
flowable.database-schema-update=false
Flowable源码修改
上面设置完成后尝试启动项目,报错信息如下:
Caused by: org.flowable.common.engine.api.FlowableException: couldn’t deduct database type from database product name ‘DM DBMS’
flowable并不认识国产数据库,需要修改文件:
在项目中创建org.flowable.common.engine.impl.AbstractEngineConfiguration文件(这边路径必须一致,打包时会覆盖源文件),修改其中getDefaultDatabaseTypeMappings方法,将达梦数据库标识为mysql:
public static Properties getDefaultDatabaseTypeMappings() {
Properties databaseTypeMappings = new Properties();
databaseTypeMappings.setProperty("H2", "h2");
databaseTypeMappings.setProperty("HSQL Database Engine", "hsql");
databaseTypeMappings.setProperty("MySQL", "mysql");
databaseTypeMappings.setProperty("MariaDB", "mysql");
databaseTypeMappings.setProperty("Oracle", "oracle");
databaseTypeMappings.setProperty("PostgreSQL", "postgres");
databaseTypeMappings.setProperty("Microsoft SQL Server", "mssql");
databaseTypeMappings.setProperty("db2", "db2");
databaseTypeMappings.setProperty("DB2", "db2");
***此处省略***
databaseTypeMappings.setProperty("DM DBMS", "mysql");// 加入达梦支持
return databaseTypeMappings;
}
liquibase-core-master 源码修改
- liquibase-core-master中False和true修改
- 针对报错进行源码修改
- 尽量以通用的方式进行转换修改
请关注博客号~ 谢谢 希望给你带来帮助



