• 金仓数据库KingbaseES客户端编程开发框架-Activiti(4. SpringBoot整合Activiti配置说明)


    4. SpringBoot整合Activiti配置说明

    SpringBoot整合Activiti的包activiti-spring-boot-starter-basic中,未提供对参数databaseType的设置,所以需要对配置方式进行扩展。

    1. 在ActivitiDatasourceProperties.java中添加新增的配置参数:

    package com.example.activiti.config;
    
    import org.springframework.boot.context.properties.ConfigurationProperties;
    import org.springframework.stereotype.Component;
    
    @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. 新建一个类继承AbstractProcessEngineAutoConfiguration类, 实现springProcessEngineConfiguration方法,在SpringProcessEngineConfiguration对象上设置需要新增的配置参数:

    package com.example.activiti.config;
    
    import java.io.IOException;
    
    import javax.sql.DataSource;
    
    import org.activiti.spring.SpringAsyncExecutor;
    import org.activiti.spring.SpringProcessEngineConfiguration;
    import org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration;
    import org.activiti.spring.boot.ActivitiProperties;
    import org.activiti.spring.boot.JpaProcessEngineAutoConfiguration;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.autoconfigure.AutoConfigureAfter;
    import org.springframework.boot.autoconfigure.AutoConfigureBefore;
    import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
    import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
    import org.springframework.boot.context.properties.EnableConfigurationProperties;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.transaction.PlatformTransactionManager;
    
    @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);
                config.setDatabaseType(this.activitiDatasourceProperties.getDatabaseType());
                return config;
            }
        }
    
    }
    
    1. 在SpringBoot的配置文件中,添加数据库类型的设置:

    spring.activiti.database-type=postgres
    

    注意

    使用KingbaseES适配Activiti时,如果使用PG形态的驱动,直接使用即可。如果使用KES形态的驱动,需要配置databaseType为postgres:

  • 相关阅读:
    【无标题】
    Docker搭建ELKF日志分析系统
    使用vue-cli来搭建vue项目
    mysql8.0笔记
    Spring5学习笔记03--Bean的生命周期
    【MySQL备份】Percona XtraBackup全量备份实战篇
    ArcGIS按像元栅格值提取栅格
    web前端设计与开发期末作品 旅游咨询网站 HTML5期末大作业 HTML+CSS旅游社网站5个页面 关于制作网页主题论述
    基于.NetCore开发博客项目 StarBlog - (10) 图片瀑布流
    修改this.$notify通知的样式
  • 原文地址:https://blog.csdn.net/arthemis_14/article/details/126868065