1)把事务交给Spring管理。
2)通过Spring获取流程引擎ProcessEngine。
在项目的src目录下添加jbpm.cfg.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<!-- <import resource="jbpm.tx.hibernate.cfg.xml" /> -->
<!-- 与Spring整合使用 -->
<import resource="jbpm.tx.spring.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.bpmn.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->
</jbpm-configuration>
在Spring的配置文件applicationContext.xml添加如下配置:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource" ref="myDataSource"/>
<!-- 映射jbpm4.4的实体配置文件 -->
<property name="mappingJarLocations">
<value>WEB-INF/lib/jbpm.jar</value>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
<!-- 自动建表 -->
hibernate.hbm2ddl.auto=update
</value>
</property>
</bean>
<!-- jbpm4.4配置 -->
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
<property name="jbpmCfg" value="jbpm.cfg.xml"></property>
</bean>
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine"/>