去年在做OA的时候使用activiti-5.22.0.0做为bpm的管理引擎,不过集成进来时候,在项目即将上线的时候发现activiti这个版本不支持事务。
所以在这里给出解决方案,希望给遇到小伙伴提供一种解决方法
<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<tx:advice id="activitiTxAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="notify*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="delegate*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="complete*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="resolve*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="claim*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="unclaim*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="new*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="suspend*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="activate*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="start*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="signal*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="submit*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
<tx:method name="execute*" propagation="REQUIRED" read-only="false" rollback-for="java.lang.Exception"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:advisor pointcut="execution(* org.activiti.engine.*Service.*(..))" advice-ref="activitiTxAdvice"/>
<aop:advisor pointcut="execution(* com.cfne.cuckoo..service..*Service.*(..))" advice-ref="activitiTxAdvice"/>
</aop:config>
<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="jobExecutorActivate" value="false"/>
<!-- Async executor通过线程池的方式管理线程。activiti默认激活使用job executor,
要使用async executor替代job executor需在配置文件中定义一下两个属性 -->
<property name="asyncExecutorActivate" value="true"/>
<property name="asyncExecutorEnabled" value="true"/>
<property name="historyLevel" value="FULL"/>
<property name="activityFontName" value="宋体"/>
<property name="labelFontName" value="宋体"/>
<!--<property name="mailServerHost" value="smtp.qq.com"/>
<property name="mailServerPort" value="465"/>
<property name="mailServerDefaultFrom" value="352004760@qq.com"/>
<property name="mailServerUsername" value="352004760@qq.com"/>
<property name="mailServerPassword" value="*******"/>
<property name="mailServerUseSSL" value="true"/>
<property name="formTypes">
<list>
<bean class="org.activiti.explorer.form.UserFormType"/>
<bean class="org.activiti.explorer.form.ProcessDefinitionFormType"/>
<bean class="org.activiti.explorer.form.MonthFormType"/>
</list>
</property>-->
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration"/>
</bean>
<!-- 初始化需要使用的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="formService" factory-bean="processEngine" factory-method="getFormService"/>
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService"/>
</beans>