前言:本文基于若依前后端分离版本(Spring Boot 3.3.0 + Vue 3 + Activiti 8.1.0)进行改造,相关教程可以在网上找到。在撰写此博客期间,笔者刚刚开始接触 Java Web,本系列下的文章内容包含大量“个人初期”视角,注意鉴别。

人大金仓?

Kingbase是基于开源数据库PostgreSQL开发的国产数据库。

所以在后续的开发中,将人大金仓视作PostgreSQL就可以解决大多数问题(这个想法对于海量数据库Vastbase是不是也是成立的?)

安装

人大金仓,一路下一步,全部安装,其中有一步骤是添加license,在下载页面也有授权文件的下载,选择开发版就好,安装好后就能看到三个软件工具:
三个工具

初步使用

运行:数据库开发管理工具。界面跟Navicat、MySQL Workbench有些像:

创建连接、创建数据库的过程还是相当相似的,不过多赘述,但是相比MySQL的数据库,多了模式这一层级。可以把它理解成一个命名空间,也就是说kingbase的数据库相对是一个更加大的集合。

  • mysql: localhost:3306/iams
  • kingbase:localhost:54321/iams?productName=PostgreSQL&currentSchema=iams

数据库迁移

kingbase并不能直接使用MySQL导出的sql文件,毕竟底层语法有区别,所以MySQL数据库迁移到kingbase还是需要进行一些工具的,比如图一中数据库迁移工具。

但是!这个软件他有bug,直接运行会出错,无法正常运行,原因在于……数据库迁移工具所在安装路径太长了

如果安装在C盘,他就是这样:

1
C:\Program Files\Kingbase\ES\V9\KESRealPro\V009R001C002B0014\ClientTools\guitools\KDts

解决方法:把文件夹复制到C盘的根目录下,比如:

1
C:\KDts\KDTS-WEB\bin

以管理员身份运行bin下面的startup.bat,运行成功之后访问:http://localhost:54523/,账号密码都是:kingbase

之后的操作可以参考:https://www.cnblogs.com/w-wu/p/17994135

虽然但是,Activiti可不支持kingbase

记得先把activiti的方言改成:database-type: postgres

当我们使用kingbase的JDBC驱动:

1
2
3
4
5
<!-- Kingbase人大金仓驱动包 -->
<dependency>
<groupId>cn.com.kingbase</groupId>
<artifactId>kingbase8</artifactId>
</dependency>

并且在application.yml文件中进行配置:

1
2
3
4
5
6
7
8
9
10
11
spring:
datasouce:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.kingbase8.Driver

druid:
master:

url: jdbc:kingbase8://localhost:54321/iams?productName=PostgreSQL&currentSchema=iams
username: system
password: 123456

那么,这个时候,就该出问题了:

1
Caused by: org.activiti.engine.ActivitiException: couldn't deduct database type from database product name 'KingbaseES'

网上有很多教适配的方法,

其一:修改jar包

https://www.hikunpeng.com/document/detail/zh/kunpengdevps/userguide/usermanual/DevKit_Porting_0059.html

其二:手动配置activiti数据库类型

亲测可用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@Configuration
@AutoConfigureAfter({DataSourceAutoConfiguration.class})
public class ActivitiConfig {


@Bean
public SpringProcessEngineConfiguration processEngineConfiguration(
DataSource dataSource,
PlatformTransactionManager transactionManager) {

SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(dataSource);
config.setTransactionManager(transactionManager);
config.setDatabaseSchemaUpdate("true");
config.setDatabaseType("postgres"); // 强制指定为 PostgreSQL
return config;
}
}

其三:直接使用postgresql驱动

亲测可用

1
2
3
4
5
<!-- postgresql驱动包 -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>

同样要修改配置文件

1
2
3
4
5
6
7
8
9
10
spring:
datasouce:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.postgresql.Driver
druid:
master:

url: jdbc:postgresql://localhost:54321/iams?productName=PostgreSQL&currentSchema=iams
username: system
password: 123456

这种方法甚至不需要给activiti进行额外的配置。