SSH整合JBPM4.4 (hibernate+Spring采用Annotation形式)
Posted on 2013-05-30 19:06 TimeFight 阅读(260) 评论(0) 收藏 举报1、首先将jbpm.hibernate.cfg.xml 和jbpm.cfg.xml复制到src目录下
jbpm.hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/OA</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">mysql</property> <property name="hibernate.hbm2ddl.auto">update</property> <mapping resource="jbpm.repository.hbm.xml" /> <mapping resource="jbpm.execution.hbm.xml" /> <mapping resource="jbpm.history.hbm.xml" /> <mapping resource="jbpm.task.hbm.xml" /> <mapping resource="jbpm.identity.hbm.xml" /> </session-factory> </hibernate-configuration>
到这里可以先生成数据库表
new SchemaExport(new Configuration().configure("jbpm.hibernate.cfg.xml")).create(false, true);
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" /> <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>
2、将以下代码复制到beans.xml
<!-- 整合Jbpm --> <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" />
</beans>
3、jar包

红色的jar不要添加
进行测试
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("beans.xml");
ProcessEngine Engine=(ProcessEngine) applicationContext.getBean("processEngine");
System.out.println("--->"+Engine);
注: 如果出现一下情况

将Tomcat6.0 lib下的el-api.jar删除 并将上面圈红色的jar将到该目录下 或者将tomcat换成tomcat5.5
浙公网安备 33010602011771号