一、前言

在上一节中我们对activiti进行了基本的介绍activiti进行了基本的介绍,同时介绍了基本的概念。

这一节,我将用一个入门程序,介绍如何使用activiti。

二、环境准备

2.1、编译器选择

这里我们使用Idea进行工作流开发,虽然Idea对于工作流的友好度不是很好,因为会有一些小的bug,但是,Idea对于Java的开发还是非常的好的。

在用Idea开发之前,我们需要在idea中安装bpmn开发的插件。方法如下

打开设置

选择plugins

搜索actiBPM

重启idea,新建文件

如果能够找到下面的创建方法,就代表成功了。

新建后出现下面的编辑页面

到现在,bpmn编辑插件就准备好了。

2.2、其他环境准备

  • JDK:1.8
  • 数据库:mysql5.7
  • activiti jar包:使用maven依赖

三、入门程序

3.1、新建maven项目

新建的maven项目目录如下

3.2、添加pom依赖

这里需要的pom依赖有以下几个:junit、druid、mysql、lombok(日志)、activiti

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.sihai</groupId><artifactId>acitvitiDemo</artifactId><version>1.0-SNAPSHOT</version><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><!-- druid --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.12</version></dependency><!-- mysql --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.30</version></dependency><!-- lombok --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.12</version></dependency><!-- logback --><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-core</artifactId><version>1.1.8</version></dependency><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.1.8</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.22</version></dependency><dependency><groupId>org.activiti</groupId><artifactId>activiti-engine</artifactId><version>5.22.0</version></dependency></dependencies><build><pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target></configuration></plugin></plugins></pluginManagement></build>
</project>

3.3、日志配置文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds"><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern></encoder></appender><!--<appender name="permission" class="ch.qos.logback.core.rolling.RollingFileAppender">--><!--<file>${catalina.home}/logs/permission.log</file>--><!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">--><!--<FileNamePattern>${catalina.home}/logs/permission.%d{yyyy-MM-dd}.log.gz</FileNamePattern>--><!--</rollingPolicy>--><!--<layout class="ch.qos.logback.classic.PatternLayout">--><!--<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>--><!--</layout>--><!--</appender>--><!----><!--<logger name="xxx" level="INFO">--><!--<appender-ref ref="permission"/>--><!--</logger>--><!-- TRACE < DEBUG < INFO < WARN < ERROR --><root level="INFO"><appender-ref ref="STDOUT"/></root></configuration>

3.4、测试实例

下面是添加一个junit测试实例,通过测试生成activiti底层需要的数据库表,总共有25张,如果数据库生成了25张表结构,则说明成功!

/*** @Author ouyangsihai* @Description 生成activiti底层数据库表结构* @Date 16:24 2019/1/26* @Param* @return**/
public class Activiti_01 {/*** @return void* @Author ouyangsihai* @Description //生成数据库表结构* @Date 20:57 2018/12/5* @Param []**/@Testpublic void test_createDatabase() {// 创建流程引擎配置信息对象ProcessEngineConfiguration pec = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();// 设置数据库的类型pec.setDatabaseType("mysql");// 设置创建数据库的方式
//        ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE(true);//如果没有数据库表就会创建数据库表,有的话就修改表结构.// ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE(false): 不会创建数据库表// ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP(create-drop): 先创建、再删除.pec.setDatabaseSchemaUpdate("true");// 设置数据库驱动pec.setJdbcDriver("com.mysql.jdbc.Driver");// 设置jdbcURLpec.setJdbcUrl("jdbc:mysql://localhost:3306/activitiTest?useUnicode=true&characterEncoding=UTF-8");// 设置用户名pec.setJdbcUsername("root");// 设置密码pec.setJdbcPassword("root");pec.setJdbcPassword("XXXX");// 构建流程引擎对象ProcessEngine pe = pec.buildProcessEngine(); // 调用访方法才会创建数据表// 调用close方法时,才会删除pe.close();}
}

3.5、运行测试实例

运行上面的测试实例后,将会生成下面的25张表结构。

日志信息

表结构

四、总结

通过上面是入门实例,就将activiti的环境准备好了!

文章有不当之处,欢迎指正,如果喜欢微信阅读,你也可以关注我的微信公众号好好学java,获取优质学习资源。

Activiti工作流从入门到入土:入门实例相关推荐

  1. 联机游戏原理入门即入土 -- 入门篇

    一.背景 联机游戏是指多个客户端共同参与的游戏, 这里主要有以下三种方式 玩家主机的 P2P 联机模式, 比如流星蝴蝶剑.以及破解游戏(盗版) 玩家进入公共服务器进行游戏,玩家资料由服务器储存的网络游 ...

  2. Activiti工作流从入门到入土:完整Hello World大比拼(Activiti工作流 API结合实例讲解)

    文章源码托管:https://github.com/OUYANGSIHAI/Activiti-learninig 欢迎 star !!! 本来想着闲来无事,前面在项目中刚刚用到了工作流 Activit ...

  3. activiti api文档_【白银人机】Activiti 工作流从入门到入土:完整 hello world 大比拼(API 结合实例讲解)...

    点击上方"好好学java",选择"置顶"公众号 重磅资源.干货,第一时间送达 重磅推荐  ① 纯福利 | 公众号资源大汇总,一年才一次! ② 重磅!!2018年 ...

  4. Activiti工作流从入门到入土:完整Hello World大比拼(Activiti工作流 API结合实例讲解)...

    文章源码托管:github.com/OUYANGSIHAI- 欢迎 star !!! 本来想着闲来无事,前面在项目中刚刚用到了工作流 Activiti 框架,写写博客的,但是,事情总是纷纷杂杂,一直拖 ...

  5. Activiti工作流从入门到入土:工作流简介

    文章源码托管:https://github.com/OUYANGSIHAI/Activiti-learninig 欢迎 star !!! 一.activiti介绍 Activiti5是由Alfresc ...

  6. 【青铜打铁篇】Activiti 工作流从入门到入土?

    点击上方"好好学java",选择"置顶"公众号 重磅资源.干货,第一时间送达 重磅推荐 ① 纯福利 | 公众号资源大汇总,一年才一次! ② 重磅!!2018年J ...

  7. activiti工作流引擎入门教程

    activiti简介 Activiti项目是一项新的基于Apache许可的开源BPM平台,从基础开始构建,旨在提供支持新的BPMN 2.0标准. Activiti是一种轻量级,可嵌入的BPM引擎,而且 ...

  8. Activiti 工作流入门到大神-任亮-专题视频课程

    Activiti 工作流入门到大神-16384人已学习 课程介绍         什么是流程.工作流作用.Activiti背景简介.Activiti流程设计器安装.Activity环境搭建.通过Hel ...

  9. Activiti工作流+idea2021入门筑基上篇-修身

    Activiti工作流 一.我不是韩立,我叫厉飞雨 一.工作流的简单了解 1.介绍:将一组任务组织起来以完成某个事件的过程 :定义了任务的触发顺序和触发条件,每个任务可以由一个或多个 软件系统 完成, ...

  10. Activiti工作流引擎基础入门【收藏可做笔记系列】

    Activiti基础-Activiti7 一.工作流介绍 1.1 概念 1.2 工作流系统 1.3 适用行业 1.4 具体应用 1.5 实现方式 二.Activiti7概述 2.1 介绍 2.1.1 ...

最新文章

  1. 面试官:你说熟悉MySQL,那来谈谈InnoDB怎么解决幻读的?
  2. c++ 把数字和中文字符分开_C语言中的字符常量与变量
  3. css 调用变量 php,PHP 变量
  4. mysql建表必须使用主键吗
  5. pytorch保存模型pth_Pytorch_trick_04
  6. 怎样用css设置图片下的投影,css – 做这种投影的最佳方法是什么?
  7. [转] TOUGH 的系列平面广告
  8. pyqt5 捕获异常确保程序不退出_Python异常处理详解(基础篇十一)
  9. 14.图像透视——人类视觉,平行线测验,其他模型,乐趣与角度_4
  10. (09)Verilog HDL异步复位
  11. Nvidia-Docker
  12. python3 asyncio 不阻塞_Python3 asyncio异步框架,让我崩溃的点
  13. Costomize Print Output
  14. 简单的P2P电影下载加速,(类似迅雷下载电影P2P加速)
  15. 女生学计算机和遥感哪个好就业,遥感专业女生就业方向 遥感专业毕业生可以从事哪些工作...
  16. 线性代数术语中英文对照
  17. MongoDB分片存储集群支撑海量数据
  18. 计算机绘图读后笔记3000字,0921计算机绘图0.doc
  19. does not have a companion object, and thus must be initialized here
  20. linux识别硬盘位置,Linux下读取硬盘的smart信息

热门文章

  1. 电脑蓝屏原因分析利器
  2. 语义分析的一些方法(下篇)
  3. 智能合约重构社会契约 (5)比特犬模型实现智能合约
  4. Kubernetes存储之Secret
  5. 347. 前 K 个高频元素(哈希表)
  6. HTML5中各种标签总结(body标签)
  7. Golang和Ethereum中的big.Int
  8. go和python计算字节数组sha1
  9. 使用资源文件绘制Win32对话框
  10. 【安全漏洞】黑客利用IE 0 day漏洞部署VBA恶意软件