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

相关文章

Spring boot整合dubbo+zookeeper的详细过程

《Springboot整合dubbo+zookeeper的详细过程》本文讲解SpringBoot整合Dubbo与Zookeeper实现API、Provider、Consumer模式,包含依赖配置、... 目录Spring boot整合dubbo+zookeeper1.创建父工程2.父工程引入依赖3.创建ap

SpringBoot3.X 整合 MinIO 存储原生方案

《SpringBoot3.X整合MinIO存储原生方案》本文详细介绍了SpringBoot3.X整合MinIO的原生方案,从环境搭建到核心功能实现,涵盖了文件上传、下载、删除等常用操作,并补充了... 目录SpringBoot3.X整合MinIO存储原生方案:从环境搭建到实战开发一、前言:为什么选择MinI

MyBatis中$与#的区别解析

《MyBatis中$与#的区别解析》文章浏览阅读314次,点赞4次,收藏6次。MyBatis使用#{}作为参数占位符时,会创建预处理语句(PreparedStatement),并将参数值作为预处理语句... 目录一、介绍二、sql注入风险实例一、介绍#(井号):MyBATis使用#{}作为参数占位符时,会

Linux下进程的CPU配置与线程绑定过程

《Linux下进程的CPU配置与线程绑定过程》本文介绍Linux系统中基于进程和线程的CPU配置方法,通过taskset命令和pthread库调整亲和力,将进程/线程绑定到特定CPU核心以优化资源分配... 目录1 基于进程的CPU配置1.1 对CPU亲和力的配置1.2 绑定进程到指定CPU核上运行2 基于

SpringBoot结合Docker进行容器化处理指南

《SpringBoot结合Docker进行容器化处理指南》在当今快速发展的软件工程领域,SpringBoot和Docker已经成为现代Java开发者的必备工具,本文将深入讲解如何将一个SpringBo... 目录前言一、为什么选择 Spring Bootjavascript + docker1. 快速部署与

Spring Boot spring-boot-maven-plugin 参数配置详解(最新推荐)

《SpringBootspring-boot-maven-plugin参数配置详解(最新推荐)》文章介绍了SpringBootMaven插件的5个核心目标(repackage、run、start... 目录一 spring-boot-maven-plugin 插件的5个Goals二 应用场景1 重新打包应用

SpringBoot+EasyExcel实现自定义复杂样式导入导出

《SpringBoot+EasyExcel实现自定义复杂样式导入导出》这篇文章主要为大家详细介绍了SpringBoot如何结果EasyExcel实现自定义复杂样式导入导出功能,文中的示例代码讲解详细,... 目录安装处理自定义导出复杂场景1、列不固定,动态列2、动态下拉3、自定义锁定行/列,添加密码4、合并

mybatis执行insert返回id实现详解

《mybatis执行insert返回id实现详解》MyBatis插入操作默认返回受影响行数,需通过useGeneratedKeys+keyProperty或selectKey获取主键ID,确保主键为自... 目录 两种方式获取自增 ID:1. ​​useGeneratedKeys+keyProperty(推

Spring Boot集成Druid实现数据源管理与监控的详细步骤

《SpringBoot集成Druid实现数据源管理与监控的详细步骤》本文介绍如何在SpringBoot项目中集成Druid数据库连接池,包括环境搭建、Maven依赖配置、SpringBoot配置文件... 目录1. 引言1.1 环境准备1.2 Druid介绍2. 配置Druid连接池3. 查看Druid监控

Java中读取YAML文件配置信息常见问题及解决方法

《Java中读取YAML文件配置信息常见问题及解决方法》:本文主要介绍Java中读取YAML文件配置信息常见问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 目录1 使用Spring Boot的@ConfigurationProperties2. 使用@Valu