在SSH2项目中添加JBPM4的开发环境

来源:互联网 发布:我想在淘宝开店 编辑:程序博客网 时间:2024/06/05 08:08

1.导入JBPM4开发所需的jar包,注意不要和原有的SSH2jar包冲突,启动tomcat,如果正常,则进行下一步的操作

2.将下面的JBPM4的映射文件代码,写入到hibernate.cfg.xml配置文件中:

   

 <!-- 导jpbm入映射文件 --><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" />
使得hibernate.cfg.xml的内容大致如下:
<pre name="code" class="java"><?xml version="1.0"?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration><session-factory><!-- 数据库信息(连接信息写到spring的配置文件中) --><property name="dialect">org.hibernate.dialect.MySQL5Dialect</property><!-- <property name="connection.url">jdbc:mysql:///itcastoa_20120216</property><property name="connection.driver_class">com.mysql.jdbc.Driver</property><property name="connection.username">root</property><property name="connection.password">root</property>--><!-- 其他配置 --><property name="show_sql">true</property><property name="hbm2ddl.auto">update</property><!-- 导入映射配置 --><mapping resource="cn/itcast/oa/domain/User.hbm.xml" /><mapping resource="cn/itcast/oa/domain/Department.hbm.xml" /><mapping resource="cn/itcast/oa/domain/Role.hbm.xml" /><mapping resource="cn/itcast/oa/domain/Privilege.hbm.xml" /><mapping resource="cn/itcast/oa/domain/Forum.hbm.xml" /><mapping resource="cn/itcast/oa/domain/Topic.hbm.xml" /><mapping resource="cn/itcast/oa/domain/Reply.hbm.xml" />    <!-- 导jpbm入映射文件 --><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>


3.将JBPM4中jbpm.cfg.xml的 <import resource="jbpm.tx.hibernate.cfg.xml" />,改成 <import resource="jbpm.tx.spring.cfg.xml" />
  <pre name="code" class="java">jbpm.cfg.xml内容如下:
<pre name="code" class="java"><?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整合需要导入jbpm.tx.spring.cfg.xml文件 -->  <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>
将该文件放在src目录下
4.在applicationContext.xml中添加下面代码:
<pre name="code" class="html">  <!-- 配置ProcessEngine --><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" />

5.测试
 <pre name="code" class="java">// 测试SessionFactory@Testpublic void testSessionFactory() throws Exception {SessionFactory sessionFactory = (SessionFactory) ac.getBean("sessionFactory");System.out.println(sessionFactory);}

<strong><span style="font-size:24px;">在SSH2项目中添加JBPM4的开发环境完成</span></strong>

0 0
原创粉丝点击