Spring、SpringBoot集成Activiti

目录

--1.Spring集成Activiti

--2.SpringBoot集成Activiti(使用starter)

--3.SpringBoot集成Activiti(手动创建@Configuration配置类)

 

1.Spring集成Activiti

 

  1>修改pom.xml

<activiti.version>6.0.0</activiti.version>


<!-- activiti集成 -->
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-engine</artifactId>
        <version>${activiti.version}</version>
    </dependency>
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring</artifactId>
        <version>${activiti.version}</version>
    </dependency>

  2>创建application-activiti.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:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd">
    
   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
           <!-- 注入数据源 -->
           <property name="dataSource" ref="dataSource"></property>
           <!-- 把事务交给spring 去管理 -->
           <property name="transactionManager" ref="transactionManager" />
        <!--            
        flase: 默认值。activiti在启动时,会对比数据库表中保存的版本,如果没有表或者版本不匹配,将抛出异常。
        true: activiti会对数据库中所有表进行更新操作。如果表不存在,则自动创建。
        create_drop: 在activiti启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表)。
        drop-create: 在activiti启动时删除原来的旧表,然后在创建新表(不需要手动关闭引擎)。 -->
           <property name="databaseSchemaUpdate" value="true"></property>
   </bean>
   
   <!-- 创建流程引擎对象 -->
   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    </bean>
    <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="formService" factory-bean="processEngine" factory-method="getFormService" />
    <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>

4>启动项目测试

 

 

猜你喜欢

转载自www.cnblogs.com/autism-dong/p/12581414.html