jbpm与spring hibernate struts整合

applicationContext.xml


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

<?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: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/context http://www.springframework.org/schema/context/spring-context-2.5.xsd

                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <!-- 自动扫描与装配bean -->

    <context:component-scan base-package="cn.itcast.oa"></context:component-scan>

    <!-- 导入外部的properties配置文件 -->

    <context:property-placeholder location="classpath:jdbc.properties" />

    <!-- 配置数据库连接池 -->

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

        <!-- =========== 数据库连接信息 =========== -->

        <property name="jdbcUrl" value="${jdbcUrl}"></property>

        <property name="driverClass" value="${driverClass}"></property>

        <property name="user" value="${username}"></property>

        <property name="password" value="${password}"></property>

        <!-- =========== 连接池的管理配置 =========== -->

        <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->

        <property name="initialPoolSize" value="3"></property>

        <!--连接池中保留的最小连接数。Default: 3 -->

        <property name="minPoolSize" value="3"></property>

        <!--连接池中保留的最大连接数。Default: 15 -->

        <property name="maxPoolSize" value="5"></property>

        <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->

        <property name="acquireIncrement" value="3"></property>

        <!--

            控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default:

            0

        -->

        <property name="maxStatements" value="8"></property>

        <!--

            maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0

        -->

        <property name="maxStatementsPerConnection" value="5"></property>

        <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->

        <property name="maxIdleTime" value="1800"></property>

    </bean>

    <!-- 配置SessionFactory -->

    <bean id="sessionFactory"

        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

        <property name="dataSource" ref="dataSource"></property>

        <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>

    </bean>

    <!-- 配置声明式的事务管理(采用基于注解的方式) -->

    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">

        <property name="sessionFactory" ref="sessionFactory"></property>

    </bean>

    <tx:annotation-driven transaction-manager="txManager" />

    <!-- 配置JBPM的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" />

</beans>

  hibernate.cfg.xml


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

<!DOCTYPE hibernate-configuration PUBLIC

    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

    <!-- 数据连接信息

        <property name="hibernate.connection.url">jdbc:mysql:///itcastoa</property>

        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

        <property name="hibernate.connection.username">root</property>

        <property name="hibernate.connection.password">1234</property>

    -->

    <property name="hibernate.dialect">

        org.hibernate.dialect.MySQL5InnoDBDialect

    </property>

    <!-- 其他配置信息 -->

    <property name="show_sql">true</property>

    <property name="hbm2ddl.auto">update</property>

    <!-- 这些映射文件是JBPM的,不能删除!!! -->

    <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" />

    <!-- 声明映射文件 -->

    <mapping resource="cn/itcast/oa/domain/User.hbm.xml" />

    <mapping resource="cn/itcast/oa/domain/Role.hbm.xml" />

    <mapping resource="cn/itcast/oa/domain/Department.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/Reply.hbm.xml" />

    <mapping resource="cn/itcast/oa/domain/Topic.hbm.xml" />

    <mapping resource="cn/itcast/oa/domain/Template.hbm.xml" />

</session-factory>

</hibernate-configuration>

删除:src/jbpm.hibernate.cfg.xml  

jbpm.cfg.xml


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

<?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" />

    -->

    <!-- 导入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>

  测试:


1

2

3

4

5

@Test

public void testProcessEngine() throws Exception {

    ProcessEngine processEngine = (ProcessEngine) ac.getBean("processEngine");

    System.out.println(processEngine);

}

  业务层获取ProcessEngine方式:

@Resource

private ProcessEngine processEngine

注意:如果启动程序的时候包错的内容是关于el表达式错误信息

处理方式:

  里面不包含jbpm的juel-api.jar juel-engine.jar juel-impl.jar这三个jar包 ,因为这三个jar包自带的el表达式需要的jar包 而且版本比tomcat里面自带的lib包的el.jar版本高,所有应该删除jbpm的这三个jar包 拷贝到tomcat的lib包下

时间: 2024-08-01 06:36:18

jbpm与spring hibernate struts整合的相关文章

spring,hibernate,struts整合

SSH整合: Spring与Hibernate整合 Spring与Struts整合 整合步骤:---------------------------------------------->本人使用的是struts2.3.4.1   hibernate3.6.0  spring3.2.5 1.导入jar文件 1)struts jar文件-->如何找? -->去源码包中struts-2.3.4.1\apps\struts-blank.war -->使用压缩文件打开struts-blan

spring+hibernate+Struts2 整合(全注解及注意事项)

最近帮同学做毕设,一个物流管理系统,一个点餐系统,用注解开发起来还是很快的,就是刚开始搭环境费了点事,今天把物流管理系统的一部分跟环境都贴出来,有什么不足的,请大神不吝赐教. 1.结构如下 2.jar包如下 3.首先是spring.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"

使用maven实现struts2 spring hibernate 的整合

今天用maven实现了struts2 , spring, hibernate 的整合. 这中间出现了不少的错误.大都是因为配置文件出错引起的.在这里整合一下: 注:这里我们实现一个登陆功能.用户从jsp页面输入用户名和密码,服务器校验其正确性后,根据正确与否跳转到不同的页面. 一,整合之后的项目结构: 可以看到,与以前的“动态网站”项目的结构不同.Maven项目中所有的框架配置文件都放在了“resources”目录下面.在“resources”中的文件最终会被copy到项目的 WEB-INF/c

Spring与Struts整合

正常的spring与struts工程文件所需jar包及配置条件下,增加如下配置: struts.xml 增加:<constant name="struts.objectFactory" value="spring" /> 配置action的时候,class直接写spring配置文件(applicationContext.xml)中的bean的ID 增加:struts2-spring-plugin-2.3.28  Jar包即可: 注意在applicatio

spring和struts整合

整合准备:导入jar包 如果只是访问action,没有做数据库方面的操作的话 只需要导入下面的jar 整合过程: 用到了struts所以需要在web.xml中配置过滤器 ,又因为使用到了spring的监听器来提高性能,所以也需要配置监听器 web.xml代码: 1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app version="2.5" 3 xmlns="http:

spring 和 struts 整合遇到的问题(学习中)

一大早就报错 org.hibernate.TransactionException: Transaction not successfully started at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.rollback(AbstractTransactionImpl.java:202) at com.ljl.test.ssh.entity.CategoryServiceImpl.save(CategorySer

Struts2 Spring Hibernate 框架整合 Annotation MavenProject

项目结构目录 pom.xml       添加和管理jar包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.

Spring+hibernate+struts

一.Spring 1.概念: 容器:容器可以装载对象,实例化对象,配置对象之间的依赖关系. IOC/DIIOC:Inversion of Control(控制反转),是指程序之间的依赖关系由依赖具体实现(如DISKUSB,UUSB),变为依赖抽象接口(USB).         一句话:依赖抽象非具体.DI:Dependency Injection(依赖注入),是指程序之间的依赖关系由容器动态注入,而非硬编码实现.        Spring里的所有类都是JavaBean,Bean就像项链的柱子

用spring+hibernate+struts 项目记录以及常用的用法进等

一.hibernate1. -----BaseDao------ // 容器注入 private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public SessionFactory getSessionFactory() { return sessionFactory;