Activity 与 springMvc相整合
准备环境:
springMvc框架及Activity所需要的jar:
创建spring-activity.xml文件,里面内容:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"
default-lazy-init="true">
<!-- 创建一个流程引擎的配置对象 -->
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<!-- 设置数据库schema的更新方式 -->
<property name="databaseSchemaUpdate" value="false" />
<!-- 是否启动jobExecutor -->
<property name="jobExecutorActivate" value="false" />
<!-- <property name="databaseSchema" value="ACT"/> -->
<!-- <property name="deploymentResources">
<list>
<value>classpath:diagrams/MyProcess.bpmn</value>
<value>classpath:diagrams/MyProcess.png</value>
</list>
</property> -->
</bean>
<!-- 创建一个流程引擎bean -->
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<!-- 创建activiti提供的各种服务 -->
<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" />
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
<bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
</beans>
然后在web.xml加入:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/spring-activiti.xml
</param-value>
</context-param>
启动就可以了。
如果报默报错 spring-activity.xml 改成如下:
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<!-- 设置数据库schema的更新方式 -->
<property name="databaseSchemaUpdate" value="true" />
<!-- 是否启动jobExecutor -->
<property name="jobExecutorActivate" value="false" />
<property name="databaseSchema" value="ACT"/>
</bean>