activiti7.0集成人大金仓数据库

说明

人大金仓数据库和mysql数据库比较相似,部分语法也类似。activiti中默认集成的是mysql数据源,而且并没有集成过人大金仓数据库。所以想要集成人大金仓数据库就要将该类的的数据源配置到其中去。这里的思路就是在流程引擎初始化数据库datasource的时候将配置文件重写。在工作流源码中我们不难看出:SpringProcessEngineConfiguration是处理工作流引擎的配置类,所以我们将AbstractProcessEngineAutoConfiguration中的ActivitiDatasourceProperties重写即可。

附录:传送门----人大金仓数据库和mysql的语法。

1、pom文件

bash 复制代码
<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
<!-- 工作流集成springboot基础包 -->
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-spring-boot-starter</artifactId>
			<version>7.1.0.M4</version>
		</dependency>
<!-- 工作流生成流程图片支持包 -->
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-image-generator</artifactId>
			<version>7.1.0.M4</version>
		</dependency>
<!-- 人大金仓驱动和数据库包 -->
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<version>42.2.9</version>
		</dependency>

		<dependency>
			<groupId>cn.com.kingbase</groupId>
			<artifactId>kingbase8</artifactId>
			<version>8.6.0</version>
		</dependency>


		<!-- 阿里 druid 数据源 -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.2.3</version>
		</dependency>
<!-- 配置文件支撑包 -->
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-spring-boot-starter-basic</artifactId>
			<version>6.0.0</version>
		</dependency>

2、application.yml

bash 复制代码
spring:
  datasource:
    url: jdbc:kingbase8://127.0.0.1:54321/activiti_test?characterEncoding=UTF-8&serverTimezone=GMT%2B8
    username: activiti
    password: 123456
    driver-class-name: com.kingbase8.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      driver-class-name: com.kingbase8.Driver
      test-while-idle: false
      validation-query: select 1
#重要配置
  activiti:
    database-type: postgres
    database-schema: public
    database-schema-update: true   
    db-history-used: true  
    history-level: full   
  application:
    name: activiti_demo
  main:
    allow-bean-definition-overriding: true
#分页支持
pagehelper:
  helperDialect: postgresql
logging:
  level:
    org.activiti.engine.impl.persistence.entity: debug

3、配置类ActivitiConfig和ActivitiDatasourceProperties

bash 复制代码
@Configuration
@AutoConfigureAfter({DataSourceAutoConfiguration.class})
@AutoConfigureBefore({JpaProcessEngineAutoConfiguration.class})
public class ActivitiConfig {


    @Configuration
    @EnableConfigurationProperties({ActivitiProperties.class})
    public static class ActivitiConfiguration extends AbstractProcessEngineAutoConfiguration {
        private ActivitiDatasourceProperties activitiDatasourceProperties;

        public ActivitiDatasourceProperties getActivitiDatasourceProperties() {
            return activitiDatasourceProperties;
        }

        @Autowired
        public void setActivitiDatasourceProperties(ActivitiDatasourceProperties activitiDatasourceProperties) {
            this.activitiDatasourceProperties = activitiDatasourceProperties;
        }

        @Bean
        @ConditionalOnMissingBean
        public SpringProcessEngineConfiguration springProcessEngineConfiguration(DataSource dataSource,
                                                                                 PlatformTransactionManager transactionManager, SpringAsyncExecutor springAsyncExecutor)
                throws IOException {
            SpringProcessEngineConfiguration config = baseSpringProcessEngineConfiguration(dataSource,
                    transactionManager, springAsyncExecutor);

            return config;
        }
		//重新构造数据源
        private SpringProcessEngineConfiguration baseSpringProcessEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager, SpringAsyncExecutor springAsyncExecutor) {
            SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
            config.setDataSource(dataSource);
            config.setTransactionManager(transactionManager);
            config.setAsyncExecutor(springAsyncExecutor);
            config.setDatabaseType(this.activitiDatasourceProperties.getDatabaseType());
            config.setDatabaseSchemaUpdate("true");
            config.setAsyncExecutorActivate(false);
            config.setAsyncExecutorCorePoolSize(1);
            config.setAsyncExecutorMaxPoolSize(1);
            return config;
        }


    }

}
bash 复制代码
@ConfigurationProperties(prefix = "spring.activiti")
@Component
public class ActivitiDatasourceProperties {


    private String databaseType;
    public String getDatabaseType() {
        return databaseType;
    }
    public void setDatabaseType(String databaseType) {
        this.databaseType = databaseType;
    }
}```
相关推荐
战神刘玉栋1 个月前
《 LiteFlow 规则引擎(1) - 入门篇》
spring·springboot·流程引擎·liteflow
老友@1 个月前
Camunda流程引擎并发性能优化
网络·数据库·性能优化·流程引擎·工作流·camunda
小米的修行之路3 个月前
windows远程连接银河麒麟系统中的人大金仓数据库
windows·人大金仓·银河麒麟
Jack_hrx3 个月前
人大金仓(Kingbase)数据库高阶函数详解
数据库·高阶函数·窗口函数·kingbase·人大金仓
w踏雪w4 个月前
《流程引擎原理与实践》开源电子书
开源·流程引擎
ciku4 个月前
Windows环境人大金仓数据库命令常规操作
数据库·人大金仓
damokelisijian8664 个月前
mysql数据库切换成kingbase(人大金仓)数据库时遇到的字段不存在问题
数据库·kingbase·人大金仓
kunwen1235 个月前
流程引擎框架
python·流程引擎·工作流
kngines6 个月前
【kettle002】kettle访问人大金仓KingbaseES数据库并处理数据至execl文件
kettle·人大金仓·kingbasees