首页 > 代码库 > Activiti 环境配置从无到有及学习心得(文档待续...)
Activiti 环境配置从无到有及学习心得(文档待续...)
最近做了个项目需要用到工作流, 工作流引擎有很多, 经比较最终选择了Activity 进行开发;
在使用之前需要搞清楚什么是工作流, 流程引擎, 流程实例 等概念, 以及对应表的含义[注: Activiti工作流共23张表, JBPM共18张表] 使自己快速熟悉工作流的这一套运作流程;
开发工具:
Eclipse (我使用的版本是 eclipse-jee-oxygen-M3-win32-x86_64)
1. 下载开发工具: 略...
2. 开发工具安装Activiti插件: 略...
3. 新建maven项目
工具栏点击"File-New-Other..." 选择 "Maven-Maven Project" 后点击Next 勾选上 Create a simple project (skip archetype selection)
点击 Next 并填写项目信息
点击Finish创建项目
配置依赖jar包
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 <groupId>cn.zjx</groupId> 5 <artifactId>activiti</artifactId> 6 <version>0.0.1-SNAPSHOT</version> 7 <packaging>war</packaging> 8 9 <dependencies> 10 <!-- junit 依赖jar --> 11 <dependency> 12 <groupId>junit</groupId> 13 <artifactId>junit</artifactId> 14 <version>4.11</version> 15 </dependency> 16 <!-- junit 依赖jar --> 17 18 <!-- MYSQL JDBC 驱动jar --> 19 <dependency> 20 <groupId>mysql</groupId> 21 <artifactId>mysql-connector-java</artifactId> 22 <version>5.1.27</version> 23 </dependency> 24 <!-- MYSQL JDBC 驱动jar --> 25 26 <!-- spring相关jar --> 27 <!-- SPRING BEGIN --> 28 <dependency> 29 <groupId>org.springframework</groupId> 30 <artifactId>spring-core</artifactId> 31 <version>4.1.0.RC2</version> 32 </dependency> 33 <dependency> 34 <groupId>org.springframework</groupId> 35 <artifactId>spring-beans</artifactId> 36 <version>4.1.0.RC2</version> 37 </dependency> 38 <dependency> 39 <groupId>org.springframework</groupId> 40 <artifactId>spring-context</artifactId> 41 <version>4.1.0.RC2</version> 42 </dependency> 43 <dependency> 44 <groupId>org.springframework</groupId> 45 <artifactId>spring-context-support</artifactId> 46 <version>4.1.0.RC2</version> 47 </dependency> 48 <dependency> 49 <groupId>org.springframework</groupId> 50 <artifactId>spring-aop</artifactId> 51 <version>4.1.0.RC2</version> 52 </dependency> 53 <dependency> 54 <groupId>org.springframework</groupId> 55 <artifactId>spring-jdbc</artifactId> 56 <version>4.1.0.RC2</version> 57 </dependency> 58 <dependency> 59 <groupId>org.springframework</groupId> 60 <artifactId>spring-orm</artifactId> 61 <version>4.1.0.RC2</version> 62 </dependency> 63 <dependency> 64 <groupId>org.springframework</groupId> 65 <artifactId>spring-tx</artifactId> 66 <version>4.1.0.RC2</version> 67 </dependency> 68 <dependency> 69 <groupId>org.springframework</groupId> 70 <artifactId>spring-web</artifactId> 71 <version>4.1.0.RC2</version> 72 </dependency> 73 <dependency> 74 <groupId>org.springframework</groupId> 75 <artifactId>spring-webmvc</artifactId> 76 <version>4.1.0.RC2</version> 77 </dependency> 78 <dependency> 79 <groupId>org.springframework</groupId> 80 <artifactId>spring-expression</artifactId> 81 <version>4.1.0.RC2</version> 82 </dependency> 83 <dependency> 84 <groupId>org.springframework</groupId> 85 <artifactId>spring-test</artifactId> 86 <version>4.1.0.RC2</version> 87 </dependency> 88 <!-- SPRING END --> 89 <!-- spring相关jar --> 90 91 <!-- ACTIVITI 工作流 BEGIN --> 92 <dependency> 93 <groupId>org.activiti</groupId> 94 <artifactId>activiti-engine</artifactId> 95 <version>5.22.0</version> 96 </dependency> 97 <dependency> 98 <groupId>org.activiti</groupId> 99 <artifactId>activiti-spring</artifactId> 100 <version>5.22.0</version> 101 </dependency> 102 <dependency> 103 <groupId>org.activiti</groupId> 104 <artifactId>activiti-json-converter</artifactId> 105 <version>5.22.0</version> 106 </dependency> 107 <dependency> 108 <groupId>org.activiti</groupId> 109 <artifactId>activiti-explorer</artifactId> 110 <version>5.22.0</version> 111 <exclusions> 112 <exclusion> 113 <artifactId>vaadin</artifactId> 114 <groupId>com.vaadin</groupId> 115 </exclusion> 116 <exclusion> 117 <artifactId>dcharts-widget</artifactId> 118 <groupId>org.vaadin.addons</groupId> 119 </exclusion> 120 <exclusion> 121 <artifactId>activiti-simple-workflow</artifactId> 122 <groupId>org.activiti</groupId> 123 </exclusion> 124 </exclusions> 125 </dependency> 126 <dependency> 127 <groupId>org.activiti</groupId> 128 <artifactId>activiti-modeler</artifactId> 129 <version>5.22.0</version> 130 </dependency> 131 <dependency> 132 <groupId>org.activiti</groupId> 133 <artifactId>activiti-diagram-rest</artifactId> 134 <version>5.22.0</version> 135 </dependency> 136 <!-- ACTIVITI 工作流 BEGIN --> 137 138 <!-- JSON 依赖, activiti似乎也是依赖此jar的 --> 139 <dependency> 140 <groupId>com.fasterxml.jackson.core</groupId> 141 <artifactId>jackson-core</artifactId> 142 <version>2.7.5</version> 143 </dependency> 144 <dependency> 145 <groupId>com.fasterxml.jackson.core</groupId> 146 <artifactId>jackson-databind</artifactId> 147 <version>2.7.5</version> 148 </dependency> 149 <dependency> 150 <groupId>com.fasterxml.jackson.core</groupId> 151 <artifactId>jackson-annotations</artifactId> 152 <version>2.7.5</version> 153 </dependency> 154 <!-- JSON 依赖, activiti似乎也是依赖此jar的 --> 155 156 <!-- 2017年5月31日 17:20:27 zjx 添加dbcp数据源和mybatis依赖jar BEGIN --> 157 <!-- MyBatis --> 158 <dependency> 159 <groupId>org.mybatis</groupId> 160 <artifactId>mybatis</artifactId> 161 <version>3.3.0</version> 162 </dependency> 163 <!--spring只针对ibatis整合依赖 --> 164 <dependency> 165 <groupId>org.mybatis</groupId> 166 <artifactId>mybatis-spring</artifactId> 167 <version>1.2.3</version> 168 </dependency> 169 <!-- 2017年5月31日 17:21:09 zjx 添加dbcp数据源和mybatis依赖jar END --> 170 171 </dependencies> 172 </project>
通过测试代码自动创建工作流相关的23张表(创建数据库activiti_primary)
CreateTablesTest
1 package activiti; 2 3 import org.activiti.engine.ProcessEngine; 4 import org.activiti.engine.ProcessEngineConfiguration; 5 import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl; 6 import org.junit.Test; 7 8 public class CreateTablesTest { 9 10 /** 11 * 测试创建activiti的23张表 12 */ 13 @Test 14 public void createActivitiTablesTest() { 15 // 1. 创建流程引擎配置类 16 ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfigurationImpl.createStandaloneProcessEngineConfiguration(); 17 // 设置流程引擎配置类 18 processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver"); 19 processEngineConfiguration.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/activiti_primary?useUnicode=true&characterEncoding=utf-8"); 20 processEngineConfiguration.setJdbcUsername("root"); 21 processEngineConfiguration.setJdbcPassword("root"); 22 23 // 2. 设置是否自动创建表; 24 /** 25 * String DB_SCHEMA_UPDATE_FALSE = "false";不能自动创建表,需要表存在 26 * DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";先删除表再创建表 27 * DB_SCHEMA_UPDATE_TRUE = "true";如果表不存在,自动创建表 28 */ 29 processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_TRUE); 30 31 // 3. 根据流程引擎配置类构建流程引擎 32 ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine(); 33 } 34 35 /** 36 * 从流程引擎中获取流程的service 37 */ 38 @Test 39 public void getServiceFromProcessEngine() { 40 41 } 42 43 }
再次查看数据库时发现23张表已经创建完成
Activiti 环境配置从无到有及学习心得(文档待续...)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。