2.Activiti6+Spring

环境及主要框架版本

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.activitigroupId>
   <artifactId>activiti-engineartifactId>
   <version>6.0.0version>
dependency>
<dependency>
   <groupId>org.activitigroupId>
   <artifactId>activiti-springartifactId>
   <version>6.0.0version>
dependency>

2.配置spring-context.xml让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>


<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是自动部署的流程

2.Activiti6+Spring_第1张图片

2.Activiti6+Spring_第2张图片
4.启动工程自动生成表
2.Activiti6+Spring_第3张图片
5.测试
参考Activiti6.0.0+Spring+Junit

你可能感兴趣的:(Activiti)