首页 > 代码库 > activiti5.12 学习笔记
activiti5.12 学习笔记
activiti与Spring整合:
<?xml version="1.0" encoding="UTF-8"?>
<beans .................................
..................................
" default-lazy-init="false">
<!-- 数据库操作 -->
<!-- <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="http://www.mamicode.com/oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="http://www.mamicode.com/jdbc:oracle:thin:@219.137.250.189:1521:orcl">
</property>
<property name="username" value="http://www.mamicode.com/ws_user"></property>
<property name="password" value="http://www.mamicode.com/ws_pass"></property>
</bean> -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="http://www.mamicode.com/oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="http://www.mamicode.com/jdbc:oracle:thin:@localhost:1521:orcl">
</property>
<property name="username" value="http://www.mamicode.com/lzj"></property>
<property name="password" value="http://www.mamicode.com/lzj"></property>
</bean>
<!--Hibernate配置-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<!-- 数据库方言 -->
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">30</prop><!-- 批量操作 -->
<prop key="hibernate.cache.use_second_level_cache">true</prop><!-- 二级缓存 -->
</props>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="http://www.mamicode.com/true" />
<property name="jobExecutorActivate" value="http://www.mamicode.com/false" />
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<!-- 这个是用activiti5几个主要的接口 -->
<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>
需要的jar包:
官网lib下的必要jar包,数据库驱动jar包以及mybatis-3.2.2.jar
activiti操作流程:
1.流程图操作:定义,部署,查看,删除
2.业务操作:启动业务(同时指定下一个任务办理人),流程关联业务(a.流程变量,b,表中的字段business_key),查询个人业务,动态指定下一个任务办理人(自关获取当前用户的上级),办理业务(将url写到图中,执行时动态获取formkey,通过配置action返回值$(#url)获取),查询任务(任务ID----->taskId------>business_key------------>申请表单信息)
注解:activiti可以使用流程表中的字段查询业务,也可以根据业务ID查询流程ID
activiti5.12 学习笔记