流程引擎Camunda:01-Springboot集成camunda

说明

springboot集成流程引擎camunda7.15.0,数据库MySQL

Camunda,Activiti,Flowable 三个框架都是从jbpm框架诞生出来的,先是有jbpm4,然后出来了一个Activiti5,Activiti5发展一段时间,又出来了一个Camunda。Activiti5发展了4年,紧接着出来了一个Flowable。

Camuda相关技术组件
设计流程->运行流程->数据分析
image.png

相关资源地址:
代码参考: https://gitee.com/lijiewei/camunda-demo.git
Camuda官网: https://camunda.com/
Camunda资源下载: https://downloads.camunda.cloud/release/camunda-bpm/
Camuda-github: https://github.com/camunda

集成过程

1. 项目代码

pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>springboot-camunda</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-camunda</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter</artifactId>
            <version>7.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
            <version>7.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
            <version>7.15.0</version>
        </dependency>
        <!-- mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.0.6</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>


        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </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>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

application.yml

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.xx.xx:3306/camunda?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&useSSL=false
    username: xxxx
    password: xxxx

camunda:
  #普通配置
  bpm:
    #自动部署
    auto-deployment-enabled: false
    #自动部署位置
    deployment-resource-pattern: classpath:processes/*.bpmn
    #数据源
    database:
      #设置建表策略
      schema-update: true
      type: mysql
    admin-user:
      id: admin
      password: admin
      firstName: admin
    filter:
      create: All tasks
    process-engine-name: demo
    job-execution:
      enabled: false

启动类CamundaDemoApplication

package com.example.camundademo;

import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@EnableProcessApplication
@SpringBootApplication
public class CamundaDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(CamundaDemoApplication.class, args);
    }
}

2. 数据库建表

https://downloads.camunda.cloud/release/camunda-bpm/wildfly/7.15/camunda-bpm-wildfly-7.15.0.zip
压缩包中有建表语句sql/create
mysql_engine_7.15.0.sql
mysql_identity_7.15.0.sql

image.png

3. 项目启动访问

  1. 启动springboot启动类CamundaDemoApplication
  2. 浏览器访问http://127.0.0.1:8080/
    账户密码:admin/admin
    登录成功后进入camunda驾驶舱(控制台)
    image.png

image.png

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×