jbpm4.3整合spring 完整案例

整合jbpm4.3和spring其实没那么困难,但是我还是搞了很久。晕ing

代码如下,首先是application.xml

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    <!-- 使Spring关注Annotation -->
    <context:annotation-config />
    <!-- 让Spring通过自动扫描来查询和管理Bean -->
    <context:component-scan base-package="com.oa" />
    <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />

    <bean id="processEngine" factory-bean="springHelper"
        factory-method="createProcessEngine" />


    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <!--
            <property name="configLocation"
            value="classpath:jbpm.hibernate.cfg.xml" />
        -->
        <property name="dataSource" ref="dataSource" />
        <property name="hibernateProperties">
            <props>
                <!--
                    <prop
                    key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                -->
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <!--<prop key="hibernate.current_session_context_class">thread</prop>-->
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <!--<prop key="hibernate.format_sql">true</prop>-->
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>jbpm.repository.hbm.xml</value>
                <value>jbpm.execution.hbm.xml</value>
                <value>jbpm.history.hbm.xml</value>
                <value>jbpm.task.hbm.xml</value>
                <value>jbpm.identity.hbm.xml</value>

            </list>
        </property>
    </bean>
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
        <!--<property name="dataSource" ref="dataSource" />-->
    </bean>

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost/jbpm2" />
        <property name="username" value="root" />
        <property name="password" value="123456" />
    </bean>
</beans>

红色部分就是整合需要修改的地方。

接下来就是jbpm.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>
  <import resource="jbpm.default.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" />
  <import resource="jbpm.businesscalendar.cfg.xml" />
  <import resource="jbpm.console.cfg.xml" />
  <process-engine-context>
    <string name="spring.cfg" value="applicationContext.xml" />
  </process-engine-context>

</jbpm-configuration>

通过这个文件将sessionfactory交给spring管理。

编码问题:

1,流程文件和数据库的编码方式要一致,最好统一为UTF-8。否则在运行过程中会产生问题。

2,如果实在不行,那在你的流程文件中就别使用中文了,全部用English吧。

 

完整案例暂时没时间上传,待有时间整理后上传.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值