spring boot 集成activiti工作流引擎

使用的集成开发工具是 Intellij idea


1.maven配置

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.wang.oa</groupId>
   <artifactId>oa</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

   <name>oa</name>
   <description>Demo project for Spring Boot</description>

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.4.2.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
   </properties>

   <dependencies>

      <!--Activiti工作流 start-->
      <dependency>
         <groupId>org.activiti</groupId>
         <artifactId>activiti-spring-boot-starter-basic</artifactId>
         <version>6.0.0.RC1</version>
      </dependency>
      <!--Activiti工作流 end-->


      <!--jpa-->

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
      <!--jpa end-->


      <!--thymeleaf模版 start-->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
      <!--thymeleaf模版 end-->

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>

      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
      </dependency>
      
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>

   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>


</project>

2.在resources目录下创建 文件夹processes

3.安装activiti插件,如下图

4.在processes目录下创建 一个test.bpmn文件的bpmn文件


5.数据库配置

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/act
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: update


6.运行test.bpmn流程

@RestController
public class DemoController {


    @Autowired
    RuntimeService runtimeService;

    @Autowired
    TaskService taskService;


    @GetMapping("/hello")
    String hello(){

        String pid = runtimeService.startProcessInstanceByKey("myProcess_1").getId();

       Task task = taskService.createTaskQuery().processInstanceId(pid).singleResult();
        return "hello world spring boot...."+task.getId();
    }
};

7.相关的工作流数据库表则创建完成


到此为止集成完成!


阅读更多
个人分类: java
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭