zoukankan      html  css  js  c++  java
  • spring boot activiti 整合

    1.pom.xml

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring-boot-starter-basic</artifactId>
        <version>5.22.0</version>
    </dependency>
    

    2. resources目录下新建processes文件夹放一个xxx.bpmn流程文件

    3. java config方式配置:config.activiti下新建一个类ActivitiConfig:

    其中数据源和事务管理器在3.spring boot mybatis druid多数据源里已经配置完,直接引用名字注入就可以了.

    package com.yunchuang.config.activiti;
    import org.activiti.spring.SpringAsyncExecutor;
    import org.activiti.spring.SpringProcessEngineConfiguration;
    import org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration;
    import org.springframework.beans.factory.annotation.Qualifier;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.transaction.PlatformTransactionManager;
    import javax.sql.DataSource;
    import java.io.IOException;
    /**
     * activiti配置文件
     * AbstractProcessEngineAutoConfiguration在activiti-spring-boot-starter-basic下
     *
     * @author 尹冬飞
     * @create 2017-04-10 10:30
     */
    @Configuration
    public class ActivitiConfig extends AbstractProcessEngineAutoConfiguration {
        static final String NAME = "master";
        //注入数据源和事务管理器
        @Bean
        public SpringProcessEngineConfiguration springProcessEngineConfiguration(
                @Qualifier(NAME + "DataSource") DataSource dataSource,
                @Qualifier(NAME + "TransactionManager") PlatformTransactionManager transactionManager,
                SpringAsyncExecutor springAsyncExecutor) throws IOException {
            return this.baseSpringProcessEngineConfiguration(dataSource, transactionManager, springAsyncExecutor);
        }
    }
    

    4.这样就可以直接调用相关的service了.测试代码:

    package com.yunchuang;
    import org.activiti.engine.RuntimeService;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    @RunWith(SpringRunner.class)
    @SpringBootTest
    public class Demo8ApplicationTests {
        @Autowired
        RuntimeService runtimeService;
        @Test
        public void contextLoads() {
            long count = runtimeService.createProcessInstanceQuery()
                    .count();
            System.out.println(count);
        }
    }
    
    原文地址:https://www.jianshu.com/p/6c9882693f35
  • 相关阅读:
    AcWing 1027. 方格取数 dp
    AcWing 1014. 登山 dp
    acwing 482. 合唱队形 dp
    LeetCode 1463. 摘樱桃II dp
    LeetCode 100. 相同的树 树的遍历
    LeetCode 336. 回文对 哈希
    LeetCode 815. 公交路线 最短路 哈希
    算法问题实战策略 DARPA大挑战 二分
    算法问题实战策略 LUNCHBOX 贪心
    AcWing 1100. 抓住那头牛 BFS
  • 原文地址:https://www.cnblogs.com/jpfss/p/11084497.html
Copyright © 2011-2022 走看看