網路上針對相關的配置已經有很多說明,本文沒有針對springmodules.jar包。
1. spring內容相關的配置,!注意spring中要配置事務資訊
<!-- jbpm.cfg.xml --><jbpm-configuration>...... <process-engine-context> <string name="spring.cfg" value="applicationContext.xml" /> </process-engine-context></jbpm-configuration>
2. 關於自訂的identity配置,即許可權管理的幾個資料表,如下
在配置sessionFactory的時候,需要添加自訂identity.hbm.xml檔案(自己配置,不再說明),在jbpm.cfg.xml中配置你自訂的IdentitySession的實現
<!-- jbpm.cfg.xml --><jbpm-configuration> ...... <!--<import resource="jbpm.identity.cfg.xml" />--> <transaction-context> <hibernate-session current="true" /> <object class="your.IdentitySessionImpl"></object> </transaction-context> </jbpm-configuration>
3. 通過spring.xml配置好sessionFactory之後,jbpm.hibernate.cfg.xml檔案可以不放到classpath下了,不過需要jbpm的特殊用途的時候,沒有做驗證。這裡請配置的朋友們,自行研究一下。
4. 在spring的上下文XML設定檔內,配置好jbpm的提供的Service的Bean就可以了
<!-- JBPM 4.4 --><bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper"><property name="jbpmCfg" value="jbpm.cfg.xml" /></bean><bean id="processEngine" factory-bean="springHelper"factory-method="createProcessEngine" /><bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"></bean><bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"></bean><bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService"></bean><bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"></bean><bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"></bean><bean id="managementService" factory-bean="processEngine" factory-method="getManagementService"></bean>
5. 配置完畢後,我的程式還出現了一個很頭疼的問題
開發環境:JDK1.6,Spring 3.0,JBPM 4.4,Hibernate 3.0,MySQL 5.0
問題描述:當我通過taskService.completeTask(taskId, translateName);,但是當任務為流程的最後一個結點的時候,出現了一個Execution外鍵的錯誤,不能刪除當前的Execution這條記錄。查看sql的執行日誌是因為在刪除Execution這條記錄之前,有一條更新操作的sql沒有執行。
問題原因:是因為hibernate的方言配置錯誤,應該採用 org.hibernate.dialect.MySQLInnoDBDialect ,而我使用的是org.hibernate.dialect.MySQLDialect