暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

金仓数据库KingbaseES客户端编程开发框架-Activiti(3. Activiti环境配置说明)

数据猿 2022-09-15
380

3. Activiti环境配置说明

本部分介绍了使用Activiti时需要的环境配置操作。

本部分包含以下章节:

3.1. 数据库连接配置

Activiti的配置信息可以通过配置文件配置,也可以直接在代码中进行配置,以下是两种方式的举例。

  1. Activiti使用配置文件配置连接信息,创建工作流需要的表。

    在activiti.cfg.xml 中增加如下声明:

    (KES形态)

    <bean id="processEngineConfiguration"
            class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
            <property name="jdbcDriver" value="com.kingbase8.Driver"></property>
            <property name="jdbcUrl" value="jdbc:kingbase8://localhost:54321/test"
                ></property>
            <property name="jdbcUsername" value="test"></property>
            <property name="jdbcPassword" value="test"></property>
            <property name="databaseType" value="postgres"></property>
            <!-- 没有表创建表 -->
            <property name="databaseSchemaUpdate" value="true"></property>
        </bean>
    

    (PG形态)

    <bean id="processEngineConfiguration"
            class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
            <property name="jdbcDriver" value="org.postgresql.Driver"></property>
            <property name="jdbcUrl" value="jdbc:postgresql://localhost:54321/test"
                ></property>
            <property name="jdbcUsername" value="test"></property>
            <property name="jdbcPassword" value="test"></property>
            <property name="databaseType" value="postgres"></property>
            <!-- 没有表创建表 -->
            <property name="databaseSchemaUpdate" value="true"></property>
        </bean>
    

    配置时根据实际情况修改 "jdbcDriver" 、"jdbcUrl" 、"databaseType"即可。

  2. Activiti使用代码配置连接信息,创建工作流需要的表。

    @Test
    public void createTable(){
        ProcessEngineConfiguration processEngineConfiguration =
            ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
        processEngineConfiguration.setJdbcDriver("org.postgresql.Driver");
        processEngineConfiguration.setJdbcUrl(
            "jdbc:postgresql://localhost:54321/test");
        processEngineConfiguration.setJdbcUsername("test");
        processEngineConfiguration.setJdbcPassword("test");
        processEngineConfiguration.setDatabaseType("postgres");
    
        processEngineConfiguration.setDatabaseSchemaUpdate(
            ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        ProcessEngine processEngine =
            processEngineConfiguration.buildProcessEngine();
    }
    

    配置时根据实际情况修改以下参数:

    1. processEngineConfiguration.setJdbcDriver

    2. processEngineConfiguration.setJdbcUrl

    3. processEngineConfiguration.setDatabaseType

3.2. 建表文件

KingbaseES兼容Activiti的核心,使用的是PG的建表语句。详细请参考:Getting Started with Activiti Core Runtime APIs 。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论