mybatis+springmvc+jbpm4整合配置

2023-12-22 21:58

本文主要是介绍mybatis+springmvc+jbpm4整合配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


花了一段时间研究了下jbpm4,后来想把它整合在maven上,但是,后来发现,maven的中央仓库和私服上要么缺了jbpm4的jar包,要么springmvc的相关jar包版本跟原项目的版本匹配不上,所以干脆将jbpm4的jar包不使用maven管理,手工进行添加,成功完成整合。

 

关键配置文件如下:

applicationContext.xml配置:

[java] view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
  4.     xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:p="http://www.springframework.org/schema/p"  
  6.     xsi:schemaLocation="    
  7.             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd    
  8.             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd    
  9.             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd    
  10.             http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd    
  11.             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"  
  12.     default-autowire="byName" default-lazy-init="false">  
  13.   
  14.     <context:property-placeholder location="classpath:db.properties" />  
  15.   
  16.     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  
  17.         destroy-method="close">  
  18.         <property name="driverClassName" value="${jdbc.driver}" />  
  19.         <property name="url" value="${jdbc.url}" />  
  20.         <property name="username" value="${jdbc.username}" />  
  21.         <property name="password" value="${jdbc.password}" />  
  22.         <property name="maxActive" value="30" />  
  23.         <property name="maxIdle" value="5" />  
  24.     </bean>  
  25.       
  26.     <bean id="transactionManager"  
  27.         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  28.         <property name="dataSource" ref="dataSource" />  
  29.     </bean>  
  30.   
  31.   
  32.     <bean id="sqlSessionFactoryBuild" class="org.mybatis.spring.SqlSessionFactoryBean">  
  33.         <!--dataSource属性指定要用到的连接池 -->  
  34.         <property name="dataSource" ref="dataSource" />  
  35.         <!-- <property name="typeAliasesPackage" value="zttc.itat.user.po"/> -->  
  36.         <property name="configLocation" value="classpath:/mybatis-config.xml" />  
  37.     </bean>  
  38.   
  39.     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
  40.         <property name="basePackage" value="zttc.itat.user.dao" />  
  41.     </bean>  
  42.       
  43.     <bean id="sessionFactoryJBPM"  
  44.         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
  45.         <property name="dataSource" ref="dataSource" />  
  46.   
  47.         <property name="configLocation">  
  48.             <value>classpath:jbpm.hibernate.cfg.xml </value>  
  49.         </property>  
  50.         <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />  
  51.         <property name="hibernateProperties">  
  52.             <props>  
  53.                 <prop key="hibernate.dialect">  
  54.                     org.hibernate.dialect.OracleDialect  
  55.                 </prop>  
  56.   
  57.                 <prop key="hibernate.query.factory_class">  
  58.                     org.hibernate.hql.ast.ASTQueryTranslatorFactory  
  59.                 </prop>  
  60.   
  61.                 <prop key="hibernate.show_sql">true </prop>  
  62.             </props>  
  63.         </property>  
  64.     </bean>  
  65.   
  66.     <bean id="transactionManagerJBPM"  
  67.         class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  68.         <property name="sessionFactory" ref="sessionFactoryJBPM" />  
  69.     </bean>  
  70.   
  71.     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
  72.         <property name="dataSource" ref="dataSource" />  
  73.     </bean>  
  74.   
  75.     <bean class="org.springframework.transaction.support.TransactionTemplate">  
  76.         <constructor-arg ref="transactionManagerJBPM"></constructor-arg>  
  77.     </bean>  
  78.     <!-- <tx:annotation-driven/> -->  
  79.     <!-- jbpm工作流 -->  
  80.     <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">  
  81.         <property name="jbpmCfg" value="jbpm.cfg.xml"></property>  
  82.     </bean>  
  83.     <bean id="processEngine" factory-bean="springHelper"  
  84.         factory-method="createProcessEngine">  
  85.     </bean>  
  86.   
  87.     <bean id="repositoryService" factory-bean="processEngine"  
  88.         factory-method="getRepositoryService" />  
  89.   
  90.   
  91.     <bean id="executionService" factory-bean="processEngine"  
  92.         factory-method="getExecutionService" />  
  93.   
  94.   
  95.     <bean id="taskService" factory-bean="processEngine"  
  96.         factory-method="getTaskService" />  
  97.   
  98.   
  99.     <bean id="historyService" factory-bean="processEngine"  
  100.         factory-method="getHistoryService" />  
  101.   
  102.   
  103.     <bean id="identityService" factory-bean="processEngine"  
  104.         factory-method="getIdentityService" />  
  105. </beans>   
<?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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd  http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"default-autowire="byName" default-lazy-init="false"><context:property-placeholder location="classpath:db.properties" /><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><property name="driverClassName" value="${jdbc.driver}" /><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /><property name="maxActive" value="30" /><property name="maxIdle" value="5" /></bean><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><bean id="sqlSessionFactoryBuild" class="org.mybatis.spring.SqlSessionFactoryBean"><!--dataSource属性指定要用到的连接池 --><property name="dataSource" ref="dataSource" /><!-- <property name="typeAliasesPackage" value="zttc.itat.user.po"/> --><property name="configLocation" value="classpath:/mybatis-config.xml" /></bean><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="zttc.itat.user.dao" /></bean><bean id="sessionFactoryJBPM"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="configLocation"><value>classpath:jbpm.hibernate.cfg.xml </value></property><property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" /><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop><prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop><prop key="hibernate.show_sql">true </prop></props></property></bean><bean id="transactionManagerJBPM"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactoryJBPM" /></bean><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"><property name="dataSource" ref="dataSource" /></bean><bean class="org.springframework.transaction.support.TransactionTemplate"><constructor-arg ref="transactionManagerJBPM"></constructor-arg></bean><!-- <tx:annotation-driven/> --><!-- 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"></bean><bean id="repositoryService" factory-bean="processEngine"factory-method="getRepositoryService" /><bean id="executionService" factory-bean="processEngine"factory-method="getExecutionService" /><bean id="taskService" factory-bean="processEngine"factory-method="getTaskService" /><bean id="historyService" factory-bean="processEngine"factory-method="getHistoryService" /><bean id="identityService" factory-bean="processEngine"factory-method="getIdentityService" />
</beans> 

 mybatis-config.xml配置文件如下:

 

[java] view plain copy print ?
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE configuration  
  3.         PUBLIC "-//mybatis.org//DTD Config 3.0//EN"  
  4.         "http://mybatis.org/dtd/mybatis-3-config.dtd">  
  5.   
  6. <configuration>  
  7.     <settings>  
  8.         <setting name="cacheEnabled" value="true" />  
  9.         <setting name="lazyLoadingEnabled" value="false" />  
  10.         <setting name="aggressiveLazyLoading" value="true" />  
  11.         <setting name="logImpl" value="LOG4J" />  
  12.     </settings>  
  13.   
  14.     <typeAliases>  
  15.         <package name="zttc.itat.user.po" />  
  16.     </typeAliases>  
  17.       
  18.     <plugins>  
  19.         <plugin interceptor="com.github.pagehelper.PageHelper">  
  20.             <!-- 支持通过Mapper接口参数来传递分页参数 -->  
  21.             <property name="supportMethodsArguments" value="true" />  
  22.         </plugin>  
  23.     </plugins>  
  24.   
  25.     <environments default="development">  
  26.         <environment id="development">  
  27.             <transactionManager type="JDBC">  
  28.                 <property name="" value="" />  
  29.             </transactionManager>  
  30.             <dataSource type="UNPOOLED">  
  31.                 <property name="driver" value="oracle.jdbc.driver.OracleDriver" />  
  32.                 <property name="url" value="jdbc:oracle:thin:@//localhost:1521/orcl" />  
  33.                 <property name="username" value="root" />  
  34.                 <property name="password" value="root" />  
  35.             </dataSource>  
  36.         </environment>  
  37.     </environments>  
  38.   
  39.     <databaseIdProvider type="DB_VENDOR">  
  40.         <property name="Oracle" value="oracle" />  
  41.     </databaseIdProvider>  
  42.   
  43.     <mappers>  
  44.         <mapper resource="zttc/itat/user/mapper/TUserMapper.xml" />  
  45.         <mapper resource="zttc/itat/user/mapper/Jbpm4DeploymentMapper.xml" />  
  46.         <mapper resource="zttc/itat/user/mapper/TLeaveApplyMapper.xml" />  
  47.     </mappers>  
  48. </configuration>  

这篇关于mybatis+springmvc+jbpm4整合配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/525611

相关文章

JVM 的类初始化机制

前言 当你在 Java 程序中new对象时,有没有考虑过 JVM 是如何把静态的字节码(byte code)转化为运行时对象的呢,这个问题看似简单,但清楚的同学相信也不会太多,这篇文章首先介绍 JVM 类初始化的机制,然后给出几个易出错的实例来分析,帮助大家更好理解这个知识点。 JVM 将字节码转化为运行时对象分为三个阶段,分别是:loading 、Linking、initialization

Spring Security 基于表达式的权限控制

前言 spring security 3.0已经可以使用spring el表达式来控制授权,允许在表达式中使用复杂的布尔逻辑来控制访问的权限。 常见的表达式 Spring Security可用表达式对象的基类是SecurityExpressionRoot。 表达式描述hasRole([role])用户拥有制定的角色时返回true (Spring security默认会带有ROLE_前缀),去

浅析Spring Security认证过程

类图 为了方便理解Spring Security认证流程,特意画了如下的类图,包含相关的核心认证类 概述 核心验证器 AuthenticationManager 该对象提供了认证方法的入口,接收一个Authentiaton对象作为参数; public interface AuthenticationManager {Authentication authenticate(Authenti

Spring Security--Architecture Overview

1 核心组件 这一节主要介绍一些在Spring Security中常见且核心的Java类,它们之间的依赖,构建起了整个框架。想要理解整个架构,最起码得对这些类眼熟。 1.1 SecurityContextHolder SecurityContextHolder用于存储安全上下文(security context)的信息。当前操作的用户是谁,该用户是否已经被认证,他拥有哪些角色权限…这些都被保

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

Java架构师知识体认识

源码分析 常用设计模式 Proxy代理模式Factory工厂模式Singleton单例模式Delegate委派模式Strategy策略模式Prototype原型模式Template模板模式 Spring5 beans 接口实例化代理Bean操作 Context Ioc容器设计原理及高级特性Aop设计原理Factorybean与Beanfactory Transaction 声明式事物

mybatis的整体架构

mybatis的整体架构分为三层: 1.基础支持层 该层包括:数据源模块、事务管理模块、缓存模块、Binding模块、反射模块、类型转换模块、日志模块、资源加载模块、解析器模块 2.核心处理层 该层包括:配置解析、参数映射、SQL解析、SQL执行、结果集映射、插件 3.接口层 该层包括:SqlSession 基础支持层 该层保护mybatis的基础模块,它们为核心处理层提供了良好的支撑。

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7