activiti工作流入门

本文介绍了如何入门Activiti工作流。首先,从指定地址下载Activiti Designer插件并配置到Eclipse。接着,创建一个Maven工程,并引入必要的Spring配置文件activiti.cfg.xml,配置数据库连接信息。最后,文章提到了初始化数据库的三种方式,包括通过代码、快速但稍慢的方式,以及不使用配置文件的方法。内容详实,适合初学者。

1,下载插件

插件下载地址:
Activiti Designer
http://Activiti.org/designer/update

在eclipse中输入以上地址:

下载完成后设置eclipses的window--preferences--activitie如下图所示

2,创建一个maven工程引入相关jar 版本可以自由选择

activation-1.1.jar
activiti-bpmn-converter-5.13.jar
activiti-bpmn-layout-5.13.jar
activiti-bpmn-model-5.13.jar
activiti-common-rest-5.13.jar
activiti-engine-5.13.jar
activiti-json-converter-5.13.jar
activiti-rest-5.13.jar
activiti-simple-workflow-5.13.jar
activiti-spring-5.13.jar
aopalliance-1.0.jar
commons-dbcp-1.4.jar
commons-email-1.2.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-pool-1.5.4.jar
h2-1.3.170.jar
hamcrest-core-1.3.jar
jackson-core-asl-1.9.9.jar
jackson-mapper-asl-1.9.9.jar
javaGeom-0.11.0.jar
jcl-over-slf4j-1.7.2.jar
jgraphx-1.10.4.2.jar
joda-time-2.1.jar
junit-4.11.jar
log4j-1.2.17.jar
mail-1.4.1.jar
mybatis-3.2.2.jar 内部依赖mybatis
mysql-connector-java-5.1.5-bin.jar
org.restlet-2.0.15.jar
org.restlet.ext.fileupload-2.0.15.jar
org.restlet.ext.jackson-2.0.15.jar
org.restlet.ext.servlet-2.0.15.jar
slf4j-api-1.7.2.jar
slf4j-log4j12-1.7.2.jar
spring-aop-3.1.2.RELEASE.jar
spring-asm-3.1.2.RELEASE.jar
spring-beans-3.1.2.RELEASE.jar
spring-context-3.1.2.RELEASE.jar
spring-core-3.1.2.RELEASE.jar
spring-expression-3.1.2.RELEASE.jar
spring-jdbc-3.1.2.RELEASE.jar
spring-orm-3.1.2.RELEASE.jar
spring-tx-3.1.2.RELEASE.jar

3.创建一个maven工程引入配置文件activiti.cfg.xml


<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    <bean id="processEngineConfiguration"
        class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">

        <property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
        <property name="jdbcUrl"
            value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf8"></property>
        <property name="jdbcUsername" value="root"></property>
        <property name="jdbcPassword" value="root"></property>
        <property name="databaseSchemaUpdate" value="true"></property>
    </bean>
</beans>

4.创建23张表

方式一代码最简单,缺点 速度有点慢:

    public void test() {

        ProcessEngine pe = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
    
        System.out.println(pe);
    }

方式二 特点快:

  File file = new File("src/main/resource/activiti.cfg.xml");
        InputStream in = new FileInputStream(file);
        ProcessEngineConfiguration
                .createProcessEngineConfigurationFromInputStream(in);

方式三:不使用配置文件activiti.cfg.xml

public static void main(String[] args) {

        // 获取config对象
        ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
                .createStandaloneProcessEngineConfiguration();
        // Jdbc设置
        String jdbcDriver = "com.mysql.jdbc.Driver";
        processEngineConfiguration.setJdbcDriver(jdbcDriver);
        String jdbcUrl = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8";
        processEngineConfiguration.setJdbcUrl(jdbcUrl);
        String jdbcUsername = "root";
        processEngineConfiguration.setJdbcUsername(jdbcUsername);
        String jdbcPassword = "root";
        processEngineConfiguration.setJdbcPassword(jdbcPassword);

        // public static final String DB_SCHEMA_UPDATE_FALSE = "false";//不自动创建新表

        // public static final String DB_SCHEMA_UPDATE_CREATE_DROP =
        // "create-drop";//每次运行创建新表

        // public static final String DB_SCHEMA_UPDATE_TRUE = "true";设置自动对表结构进行改进和升级
        // 设置是否自动更新
        processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        // 获取引擎对象
        ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
        processEngine.close();
    
    }

(未完待续)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值