Spring整合activiti配置processEngine

配置xml数据时,可以直接在配置文件中填写,也可以采用properties配置文件的方式加载

采用配置文件的方式需要使用到${参数}的方式获取。

引用配置文件的方式:<context:property-placeholder location="classpath:properties文件目录" />

applicationContaxt.xml配置信息如下所示

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

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="         http://www.springframework.org/schema/beans              http://www.springframework.org/schema/beans/spring-beans-4.2.xsd         http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context-4.2.xsd         http://www.springframework.org/schema/aop         http://www.springframework.org/schema/aop/spring-aop-4.2.xsd         http://www.springframework.org/schema/tx         http://www.springframework.org/schema/tx/spring-tx-4.2.xsd         ">

<!-- Hibernate5 --> <!-- 加载资源文件 其中包含变量信息,必须在Spring配置文件的最前面加载,即第一个加载 -->

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

<!-- 该 BeanPostProcessor 将自动对标注 @Autowired 的 Bean 进行注入 -->

<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />

<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>

<!-- 可以加多个 -->

<value>cn/xxxx/xxxxx/xx.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show\_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
<prop key="hibernate.temp.use\_jdbc\_metadata\_defaults">false</prop><!-- 不显示驱动关于lob的检测:Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException -->
<prop key="hibernate.jdbc.batch\_size">50</prop>
<prop key="cache.use\_second\_level\_cache">${cache.use_second_level_cache}</prop>
<prop key="hibernate.cache.use\_query\_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.region.factory\_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
<prop key="javax.persistence.validation.mode">none</prop>

<!-- <prop key="hibernate.current\_session\_context\_class">thread</prop> hibernate4以上版本使用thread时不能使用事务托管,因其取得的session不是来源于spring了-->

<prop key="hibernate.current\_session\_context\_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
<prop key="hibernate.transaction.factory\_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
</props>
</property>
</bean>

<!-- jndi外部连接池方式 <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">    <property name="jndiName" value="XXX"/> </bean> --> <!-- 直接连接方式 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.user}" /> <property name="password" value="${jdbc.pass}" /> </bean> --> <!-- 连接池方式 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClassName}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.user}" /> <property name="password" value="${jdbc.pass}" />         <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->           <property name="initialPoolSize" value="${c3p0.initialPoolSize}"/>         <!--连接池中保留的最小连接数。Default: 3 -->         <property name="minPoolSize" value="${c3p0.minPoolSize}"/>         <!--连接池中保留的最大连接数。Default: 15 -->         <property name="maxPoolSize" value="${c3p0.maxPoolSize}"/>         <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->         <property name="acquireIncrement" value="${c3p0.acquireIncrement}"/>         <!-- 控制数据源内加载的PreparedStatements数量(全局)。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->         <property name="maxStatements" value="50"/>         <!-- maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 -->         <property name="maxStatementsPerConnection" value="50"/>         <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->         <property name="maxIdleTime" value="1800"/> <!-- 当连接池连接耗尽时,客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒。默认: 0 --> <property name="checkoutTimeout" value="3000"/> <!--定义在从数据库获取新连接失败后重复尝试的次数。默认值: 30 ;小于等于0表示无限次--> <property name="acquireRetryAttempts" value="2"/> <!--重新尝试的时间间隔,默认为:1000毫秒--> <property name="acquireRetryDelay" value="2000"/> <!--关闭连接时,是否提交未提交的事务,默认为false,即关闭连接,回滚未提交的事务 -->         <property name="autoCommitOnClose" value="false"/> <!--c3p0将建一张名为Test的空表,并使用其自带的查询语句进行测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。你不能在这张Test表上进行任何操作,它将只供c3p0测试使用。默认值: null --> <!--<property name="automaticTestTable" value=""/>--> <!--如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常,但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false-->    <property name="breakAfterAcquireFailure" value="false"/> <!--每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 --> <property name="idleConnectionTestPeriod" value="300"/> </bean> <!-- 配置Hibernate事务管理器 --> <!--hibernate4以上必须配置为开启事务(可能为只读事务) 否则 getCurrentSession()获取不到--> 

<bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 如果此处提示Error occured processing XML 'org/springframework/transaction/interceptor/TransactionInterceptor'.可以引入aopalliance-1.0.jar这个jar包来解决 -->

<tx:advice id="txAdvice" transaction-manager="txManager">
         tx:attributes
             <tx:method name="*_trans" propagation="REQUIRED" />
             <tx:method name="*" propagation="NEVER" read-only="true"/>
         </tx:attributes>
    </tx:advice>
<aop:config proxy-target-class="true">

<!--aop expression参考:http://blog.csdn.net/kkdelta/article/details/7441829 -->

         <!-- <aop:advisor advice-ref="txAdvice" pointcut="execution(\* dao.\*.\*(..))"/> -->
         <aop:pointcut expression="execution(* cn.xxxx.dao.*.*(..)) or 
          execution(* xxx.yyy.zzzz.*.*(..))" id="pointcut"/>
         <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/>
     </aop:config>
     

<!-- activiti5集成spring配置,此为切入点,id不能改名,额外需要jackson相关包3个, 需要的架包参考用户手册集成说明内的,不要盲目的加入war示例内的所有jar --> <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> <!-- 配置的是ProcessEngineConfiguration.java类的属性 --> <property name="dataSource" ref="dataSource" /> <property name="transactionManager" ref="txManager" /> <property name="databaseSchemaUpdate" value="false" /><!-- 此处通常应该为false --> <property name="jobExecutorActivate" value="false" /> <property name="history" value="none" /> <property name="dbIdentityUsed" value="false" /> <property name="dbHistoryUsed" value="false" /><!-- 不检测历史表是否存在,应对Activiti database problem: Tables missing for component(s) history, identity --> <!-- <property name="createDiagramOnDeploy" value="false" />发布时是否包括流程图片png--> <property name="activityFontName" value="宋体"/><!-- 避免发布的图片和xml遇到中文时乱码 -->    <property name="labelFontName" value="宋体"/>    <property name="xmlEncoding" value="gbk"/><!-- 解析xml流程文件所使用的字符集,默认为utf8,依据数据库来 --> </bean> <!-- 引擎实例,通常就是用到它 --> <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"> <property name="processEngineConfiguration" ref="processEngineConfiguration" /> </bean> <!-- activiti流程的辅助类,仅后台发布和重绑流程用到 --> <bean id="actDeploy" class="cn.xxxxx.activiti.ActDeploy"> </bean> <!-- 创建activiti提供的各种服务 --> <!-- 工作流仓储服务 <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /> --> <!-- 工作流运行服务 <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /> --> <!-- 工作流任务服务 <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> --> <!-- 工作流历史数据服务 <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> --> <!-- 工作流管理服务 <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /> --> <!-- 工作流唯一服务 <bean id="IdentityService" factory-bean="processEngine" factory-method="getIdentityService" /> --> </beans>
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

Spring整合activiti配置processEngine - HelloWorld