在原有的ssm框架中集成activiti,只需添加activiti依赖和向spring的配置文件中引入activiti的配置文件即可:
1 pom依赖;5.20.0版本
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.20.0</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>5.20.0</version>
</dependency>
2 配置文件的引入
<import resource="activiti-contenxt.xml" />
3 activiti配置文件
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource"></property>
<property name="transactionManager" ref="txManager"></property>
<property name="databaseSchemaUpdate" value="true"></property>
<property name="deploymentResources">
<list>
<value>classpath*:/activiti/*</value>
</list>
</property>
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration"></property>
</bean>
<bean id="repositoryService" factory-bean="processEngine"
factory-method="getRepositoryService"></bean>
<bean id="runtimeService" factory-bean="processEngine"
factory-method="getRuntimeService" />
<bean id="formService" factory-bean="processEngine"
factory-method="getFormService" />
<bean id="identityService" factory-bean="processEngine"
factory-method="getIdentityService" />
<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" />
4 activiti配置文件解读
4.1 processEngineConfiguration 将activiti的引擎配置到spring容器中
4.2 dataSource 使用spring管理的数据源
4.3 transactionManager 使用spring管理的事务管理器
4.4 databaseSchemaUpdate 数据库脚本更新策略
false:什么都不做
true:表不存在时,自动创建或者升级
create-drop:创建引擎时初始化表,销毁引擎时删除表
4.5 deploymentResources:创建引擎时自动部署指定流程文件
4.6 其他bean:activiti核心对象配置到spring容器中