全部源码:公众号搜索资小库,回复dm获取源码
1.整合达梦
1.1 达梦驱动下载
MyBatis-Plus 框架 | 达梦技术文档 (dameng.com)
1.2 数据迁移
怎么安装数据库,很多大佬有帖子,搜一下达梦先建立用户,使用DM管理工具
链接数据库
输入用户名密码等,再创建用户,咱这边用户和数据库名称保持一致,这样就可以不加数据库头了我们的SQL,并赋予一定权限
使用DM数据迁移工具进行数据迁移,先新建迁移,然后下一步下一步,数据就迁移完了
1.2安装驱动
将DmJdbcDriver18.jar移动到你觉得合适的地方,我这边移动到了
${project.basedir}/src/lib/DmJdbcDriver18.jar 这个地方
1.3 pom准备
删除mysql驱动,全局搜索xml类型的文件内容"mysql-",删除mysql的相关依赖,怕出错不想删除也行,增加达梦驱动
<dependency><groupId>com.dm</groupId><artifactId>Dm18JdbcDriver</artifactId><version>1.8</version><scope>system</scope><systemPath>${project.basedir}/src/lib/DmJdbcDriver18.jar</systemPath></dependency>
1.4 yml修改
driverClassName: dm.jdbc.driver.DmDriverurl: jdbc:dm://127.0.0.1:5236/BIMS_SAAS?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&nullCatalogMeansCurrent=trueusername: BIMS_SAASpassword: xxxxx
至此达梦就整合完了
2.activiti整合达梦
主要是4个文件,但是源码中和你在class中copy的代码不是很相同,我们使用源码中的代码,
以下文件,目录结构自己看图
ProcessEngineConfigurationImpl增加对DM的支持
public static final String DATABASE_TYPE_DM = "dm";public static Properties getDefaultDatabaseTypeMappings() {Properties databaseTypeMappings = new Properties();databaseTypeMappings.setProperty("DM DBMS", DATABASE_TYPE_DM);}
这里修改成Oracle,因为达梦对oracle支持不错
if (databaseType != null) {if (ProcessEngineConfigurationImpl.DATABASE_TYPE_DM.equals(databaseType)){databaseType = ProcessEngineConfigurationImpl.DATABASE_TYPE_ORACLE;}properties.load(getResourceAsStream("org/activiti/db/properties/"+databaseType+".properties"));}
DbSqlSession
这个地方要改一下,也是让他支持Oracle
public String getResourceForDbOperation(String directory, String operation, String component) {String databaseType = dbSqlSessionFactory.getDatabaseType();if (ProcessEngineConfigurationImpl.DATABASE_TYPE_DM.equals(databaseType)){databaseType = ProcessEngineConfigurationImpl.DATABASE_TYPE_ORACLE;}return "org/activiti/db/" + directory + "/activiti." + databaseType + "." + operation + "." + component + ".sql";}
DbSqlSessionFactory
也是选择Oracle
protected void initBulkInsertEnabledMap(String databaseType) {bulkInsertableMap = new HashMap<Class<? extends Entity>, Boolean>();for (Class<? extends Entity> clazz : EntityDependencyOrder.INSERT_ORDER) {bulkInsertableMap.put(clazz, Boolean.TRUE);}// Only Oracle is making a fuss in one specific case right nowif ("oracle".equals(databaseType) || "dm".equals(databaseType)) {bulkInsertableMap.put(EventLogEntryEntityImpl.class, Boolean.FALSE);}}
AbstractQuery
增加对dm支持
if (nullHandlingOnOrder != null) {if (nullHandlingOnOrder.equals(NullHandlingOnOrder.NULLS_FIRST)) {if (ProcessEngineConfigurationImpl.DATABASE_TYPE_H2.equals(databaseType) || ProcessEngineConfigurationImpl.DATABASE_TYPE_HSQL.equals(databaseType)|| ProcessEngineConfigurationImpl.DATABASE_TYPE_POSTGRES.equals(databaseType) || ProcessEngineConfigurationImpl.DATABASE_TYPE_ORACLE.equals(databaseType)|| ProcessEngineConfigurationImpl.DATABASE_TYPE_DM.equals(databaseType)) {orderBy = orderBy + defaultOrderByClause + " NULLS FIRST";} else if (ProcessEngineConfigurationImpl.DATABASE_TYPE_MYSQL.equals(databaseType)) {orderBy = orderBy + "isnull(" + column + ") desc," + defaultOrderByClause;} else if (ProcessEngineConfigurationImpl.DATABASE_TYPE_DB2.equals(databaseType) || ProcessEngineConfigurationImpl.DATABASE_TYPE_MSSQL.equals(databaseType)) {orderBy = orderBy + "case when " + column + " is null then 0 else 1 end," + defaultOrderByClause;} else {orderBy = orderBy + defaultOrderByClause;}} else if (nullHandlingOnOrder.equals(NullHandlingOnOrder.NULLS_LAST)) {if (ProcessEngineConfigurationImpl.DATABASE_TYPE_H2.equals(databaseType) || ProcessEngineConfigurationImpl.DATABASE_TYPE_HSQL.equals(databaseType)|| ProcessEngineConfigurationImpl.DATABASE_TYPE_POSTGRES.equals(databaseType) || ProcessEngineConfigurationImpl.DATABASE_TYPE_ORACLE.equals(databaseType)||ProcessEngineConfigurationImpl.DATABASE_TYPE_DM.equals(databaseType)) {orderBy = orderBy + column + " " + sortOrder + " NULLS LAST";} else if (ProcessEngineConfigurationImpl.DATABASE_TYPE_MYSQL.equals(databaseType)) {orderBy = orderBy + "isnull(" + column + ") asc," + defaultOrderByClause;} else if (ProcessEngineConfigurationImpl.DATABASE_TYPE_DB2.equals(databaseType) || ProcessEngineConfigurationImpl.DATABASE_TYPE_MSSQL.equals(databaseType)) {orderBy = orderBy + "case when " + column + " is null then 1 else 0 end," + defaultOrderByClause;} else {orderBy = orderBy + defaultOrderByClause;}}
pom
<dependency><groupId>javax.persistence</groupId><artifactId>javax.persistence-api</artifactId></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>5.3.7.Final</version><exclusions><exclusion><groupId>commons-collections</groupId><artifactId>commons-collections</artifactId></exclusion></exclusions></dependency>
yml
# 数据源配置
spring:jpa:properties:hibernate:dialect: org.hibernate.dialect.Oracle10gDialectshow-sql: ture
这样第一次启动应该可以启动创建表了,启动不起来多半是一些SQL或者其他JAVA问题不兼容导致的
第一次执行完,关闭activiti更新表
spring: activiti:check-process-definitions: false# 检测身份信息表是否存在db-identity-used: falsedatabase-schema-update: none
关注公众号:资小库,问题快速答疑解惑