码迷,mamicode.com
首页 > 其他好文 > 详细

Activiti6-快速开始

时间:2019-06-24 12:24:48      阅读:358      评论:0      收藏:0      [点我收藏+]

标签:log4j   block   pac   key   lin   开始   配置文件   aml   ==   

下载
https://www.activiti.org/download-links
快速开始
https://www.activiti.org/quick-start
用户指南
https://www.activiti.org/userguide/
相关资料
http://www.kafeitu.me/activiti.html
http://blog.csdn.net/u013517797/article/category/6732665

1.根据快速开始操作,创建maven工程,配置相关依赖, $actVer改为6.0.0 本例使用mysql替代h2

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-engine</artifactId>
    <version>6.0.0</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.21</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.21</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>6.0.6</version>
</dependency>

2.加入配置文件/src/main/resources/log4j.properties

log4j.rootLogger=DEBUG, ACT
log4j.appender.ACT=org.apache.log4j.ConsoleAppender
log4j.appender.ACT.layout=org.apache.log4j.PatternLayout
log4j.appender.ACT.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n

3.mysql创建数据库并连接
技术图片

4.获取流程引擎对象ProcessEngine
4.1.通过代码设置

// 引擎配置
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()
        .setJdbcUrl("jdbc:mysql://localhost:3306/activiti").setJdbcUsername("root")
        .setJdbcPassword("pwd")
        .setJdbcDriver("com.mysql.jdbc.Driver")
        .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
// 获取流程引擎对象
ProcessEngine processEngine = cfg.buildProcessEngine();

4.2.通过activiti.cfg.xml配置文件

ProcessEngineConfiguration cfg = ProcessEngineConfiguration
        .createProcessEngineConfigurationFromResource("activiti.cfg.xml");
ProcessEngine processEngine = cfg.buildProcessEngine();

配置文件activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       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">

    <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti"/>
        <property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
        <property name="jdbcUsername" value="root"/>
        <property name="jdbcPassword" value="pwd"/>
        <property name="databaseSchemaUpdate" value="true"/>
    </bean>

</beans>

执行后初始化数据表如下
技术图片
5.安装BPM插件
5.1 IDEA搜索并安装BPM插件 Business Process Management

技术图片

加入示例中的xml /src/main/resources/onboarding.bpmn20.xml
打开xml可以看到流程图
技术图片
5.2.IDEA的BPM插件使用体检较差,建议使用eclipse插件
安装插件 Install New Software http://activiti.org/designer/update/
Activiti 5.10支持直接部署扩展名为bpmn的流程文件,设计器打开如下:
技术图片

6.下面就可以为所欲为了

// 启动流程
ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("myProcess");
System.out.println("process id" + pi.getId());
System.out.println("process name" + pi.getName());

// 获取任务
TaskService taskService = processEngine.getTaskService();
List<Task> list = taskService.createTaskQuery().taskAssignee("lili").list();
System.out.println("任务个数" + list.size());
if (list != null && list.size() > 0) {
    for (Task t : list) {
        System.out.print(t.getId() + ",");
        System.out.print(t.getName() + ",");
        System.out.print(t.getAssignee() + ",");
        System.out.println(t.getProcessInstanceId());
    }
}
原文地址:https://blog.csdn.net/gaojingyuan/article/details/78979716

Activiti6-快速开始

标签:log4j   block   pac   key   lin   开始   配置文件   aml   ==   

原文地址:https://www.cnblogs.com/jpfss/p/11076261.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!