其他分享
首页 > 其他分享> > springboot+camunda实现工作流-1

springboot+camunda实现工作流-1

作者:互联网

1.在camunda modeler工具里面写流程,任务执行指明Java类

 

 2.保存文件放在resources目录下,并建立一个processes.xml的空文件

 

 3.依赖配置

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- camunda依赖 -->
        <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>

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

4.yml配置:建立一个空数据库既可以,运行后会自动建表

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/camunda
    username: root
    password: root
camunda:
  bpm:
    admin-user:
      id: admin
      password: admin
      first-name: admin
    filter:
      create: All tasks
    #指定数据库类型
      database:
          type: mysql
    #自动部署resources下面的bpmn文件
    auto-deployment-enabled: true
    #禁止index跳转到Camunda自带的管理界面,默认true
#    webapp:
#      index-redirect-enabled: false

5.编写任务中的Java执行类

package com.example.camunda.email;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @program: camunda
 * @description: 发送邮件
 * @author: Mr.HuangDaDa
 * @create: 2021-12-28 17:08
 **/
public class SendEmail implements JavaDelegate {
    private final Logger logger = LoggerFactory.getLogger(SendEmail.class);
    @Override
    public void execute(DelegateExecution execution) throws Exception {
        logger.info("发邮件成功!!!");
    }
}

6.登录执行,点击tasklist,

 

 

 

 

 

 7.结果:已经成功执行任务

 

标签:bpm,springboot,实现,spring,boot,mysql,org,camunda
来源: https://www.cnblogs.com/hyy9527/p/15743896.html