环境及主要框架版本
JDK 1.8.0_112
maven 3.3.9
springframework 4.3.10.RELEASE
mybatis 3.2.8
mysql 5.1.43
logback 1.2.3
1.现有工程加入工作流引擎及兼容包
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>6.0.0</version>
</dependency>
2.配置spring-context.xml让activiti使用工程原有的连接池及事务管理
<!-- activiti配置 -->
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration"/>
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource"/>
<property name="transactionManager" ref="transactionManager"/>
<!--自动建表-->
<property name="databaseSchemaUpdate" value="true"/>
<!--自动部署流程图-->
<property name="deploymentResources" value="classpath*:/diagrams/*"/>
</bean>
<!-- activiti主要的Service -->
<bean id="repositoryService" factory-bean="processEngine"
factory-method="getRepositoryService"/>
<bean id="runtimeService" factory-bean="processEngine"
factory-method="getRuntimeService"/>
<bean id="taskService" factory-bean="processEngine"
factory-method="getTaskService"/>
<bean id="historyService" factory-bean="processEngine"
factory-method="getHistoryService"/>
<bean id="managementService" factory-bean="processEngine"
factory-method="getManagementService"/>
3.resources目录加入流程图目录diagrams
工程启动后,修改后流程图可直接覆盖diagrams中前原本的流程,自动部署
下图部署ID为2501是自动部署的流程
4.启动工程自动生成表
5.测试
参考Activiti6.0.0+Spring+Junit