本文介绍基于mysql数据库,如何实现camunda与springboot的集成,如何实现基于springboot运行camunda开源流程引擎。

一、创建springboot工程

使用IDEA工具,选择File->New->Project,选择Spring Initialzr

输入springboot工程基本信息,本示例命名为“camunda-demo1”, jdk版本选择8

在选择springboot组件的时候,需要选择Spring Web、JDBC API、MySql Driver 这三个组件。点击下一步完成即可。

二、修改maven配置

2.1、修改springboot版本号

由于camunda版本与springboot版本有匹配关系,所以需要修改springboot版本为2.4.3,

官方推荐Camunda7.1.5版本使用Spring Boot 2.4.x版本

具体配置参考camunda官方说明文档:https://docs.camunda.org/manual/7.15/user-guide/spring-boot-integration/version-compatibility/

Pom.xm代码片段:

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>2.4.3</version>
  5. <relativePath/> <!-- lookup parent from repository -->
  6. </parent>

2.2、引入camunda包

由于本示例要使用camunda流程引擎、web界面、Rest服务接口,所以需要导入camunda-bpm-spring-boot-starter、camunda-bpm-spring-boot-starter-rest、camunda-bpm-spring-boot-starter-webapp这三个依赖包,如果仅仅是使用流程引擎,只需要引入camunda-bpm-spring-boot-starter就可以了。

完整的pom.xml文件如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.4.3</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.example</groupId>
  12. <artifactId>camunda-demo1</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>camunda-demo1</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>1.8</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-web</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-jdbc</artifactId>
  27. </dependency>
  28. <dependency>
  29. <groupId>mysql</groupId>
  30. <artifactId>mysql-connector-java</artifactId>
  31. <scope>runtime</scope>
  32. </dependency>
  33. <dependency>
  34. <groupId>org.springframework.boot</groupId>
  35. <artifactId>spring-boot-starter-test</artifactId>
  36. <scope>test</scope>
  37. </dependency>
  38. <dependency>
  39. <groupId>org.camunda.bpm.springboot</groupId>
  40. <artifactId>camunda-bpm-spring-boot-starter</artifactId>
  41. <version>7.15.0</version>
  42. </dependency>
  43. <dependency>
  44. <groupId>org.camunda.bpm.springboot</groupId>
  45. <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
  46. <version>7.15.0</version>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.camunda.bpm.springboot</groupId>
  50. <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
  51. <version>7.15.0</version>
  52. </dependency>
  53. </dependencies>
  54. <build>
  55. <plugins>
  56. <plugin>
  57. <groupId>org.springframework.boot</groupId>
  58. <artifactId>spring-boot-maven-plugin</artifactId>
  59. </plugin>
  60. </plugins>
  61. </build>
  62. </project>

三、修改application.yaml配置

打开工程目录下的main\resources\application.yaml文件,如果没有该文件,手动新建一个,录入如下信息。

  1. # Find more available configuration properties on the following pages of the documentation.
  2. # https://docs.camunda.org/manual/latest/user-guide/camunda-bpm-run/#configure-camunda-bpm-run
  3. # https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/configuration/#camunda-engine-properties
  4. camunda.bpm:
  5. generic-properties.properties:
  6. javaSerializationFormatEnabled: true
  7. admin-user:
  8. id: demo
  9. password: demo
  10. run:
  11. # https://docs.camunda.org/manual/latest/user-guide/camunda-bpm-run/#cross-origin-resource-sharing
  12. cors:
  13. enabled: true
  14. allowed-origins: "*"
  15. # datasource configuration is required
  16. spring.datasource:
  17. url: jdbc:mysql://127.0.0.1:3306/camunda-715?characterEncoding=UTF-8&useUnicode=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
  18. driver-class-name: com.mysql.cj.jdbc.Driver
  19. username: root
  20. password: root
  21. # By default, Spring Boot serves static content from any directories called /static or /public or /resources or
  22. # /META-INF/resources in the classpath. To prevent users from accidentally sharing files, this is disabled here by setting static locations to NULL.
  23. # https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc-static-content
  24. spring.web.resources:
  25. static-locations: NULL

本示例使用的是mysql数据库,数据库URL、username、 password 跟后面数据库信息保存一致。

四、创建mysql数据库

Camunda默认使用已预先配置好的H2数据库,本示例使用mysql数据库,需要提前创建mysql数据库并导入Camunda建表脚本。

为Camunda平台创建一个数据库模式,名称为camunda715

导入SQL脚本。执行创建所有必需的表和默认索引的SQL DDL脚本。这些脚本可以在configuration/sql/create文件夹中找到。共2个脚本,都需要导入。

导入完成后的表结构,共40张表:

详细配置方法参考:https://lowcode.blog.csdn.net/article/details/117564836

五、启动springboot工程

创建springboot工程的时候,自动生成了SpringBootApplication启动类,运行改类启动即可。

package com.example.demo1;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CamundaDemo1Application {

    public static void main(String[] args) {
        SpringApplication.run(CamundaDemo1Application.class, args);
    }

}

六、登录访问camunda

访问:http://localhost:8080,

默认账号密码demo/demo

登录成功后进入camunda控制台

至此,完成了springboot2.4.3+camunda7.15+mysql的集成,后续的如何设计流程、如何启动流程、如何审批流程等操作,跟非springboot方式是一致的,请参考前面的文章。

https://lowcode.blog.csdn.net/article/details/117518828

https://lowcode.blog.csdn.net/article/details/118055189

体验环境:http://www.yunchengxc.com

如何实现Springboot+camunda+mysql的集成的更多相关文章

  1. spring-boot+mybatisPlus+shiro的集成demo 我用了5天

    spring-boot + mybatis-plus + shiro 的集成demo我用了五天 关于shiro框架,我还是从飞机哪里听来的,就连小贱都知道,可我母鸡啊.简单百度了下,结论很好上手,比s ...

  2. springboot学习笔记:11.springboot+shiro+mysql+mybatis(通用mapper)+freemarker+ztree+layui实现通用的java后台管理系统(权限管理+用户管理+菜单管理)

    一.前言 经过前10篇文章,我们已经可以快速搭建一个springboot的web项目: 今天,我们在上一节基础上继续集成shiro框架,实现一个可以通用的后台管理系统:包括用户管理,角色管理,菜单管理 ...

  3. 基于springboot+bootstrap+mysql+redis搭建一套完整的权限架构【六】【引入bootstrap前端框架】

    https://blog.csdn.net/linzhefeng89/article/details/78752658 基于springboot+bootstrap+mysql+redis搭建一套完整 ...

  4. springboot+jpa+mysql+redis+swagger整合步骤

    springboot+jpa+MySQL+swagger框架搭建好之上再整合redis: 在电脑上先安装redis: 一.在pom.xml中引入redis 二.在application.yml里配置r ...

  5. springboot+jpa+mysql+swagger整合

    Springboot+jpa+MySQL+swagger整合 创建一个springboot web项目 <dependencies> <dependency>      < ...

  6. Springboot+Mybatis+MySQL实例练习时踩坑记录

    最近刚开始学习后端,直接让上手学习Springboot+Mybatis+MySQL对CRUD的实例,虽然实例不难,但是上面的三个知识我都不懂,就有点为难我了 所以经常遇到一个点卡自己很久的情况,这里列 ...

  7. 微服务学习二:springboot与swagger2的集成

    现在测试都提倡自动化测试,那我们作为后台的开发人员,也得进步下啊,以前用postman来测试后台接口,那个麻烦啊,一个字母输错就导致测试失败,现在swagger的出现可谓是拯救了这些开发人员,便捷之处 ...

  8. SpringBoot Docker Mysql安装,Docker安装Mysql

    SpringBoot Docker Mysql安装,Docker安装Mysql ================================ ©Copyright 蕃薯耀 2018年4月8日 ht ...

  9. 微服务之分布式跟踪系统(springboot+zipkin+mysql)

    通过上一节<微服务之分布式跟踪系统(springboot+zipkin)>我们简单熟悉了zipkin的使用,但是收集的数据都保存在内存中重启后数据丢失,不过zipkin的Storage除了 ...

随机推荐

  1. 关于页面中css某些情况下出现不知原因的隔断解决办法

    第一种方法:body{margin:0px;padding:0px position:absolute; top:0px;left:0px;} html{ width:100%; overflow-x ...

  2. 编译python(cpython)的源码及其用途

    获取python的源码 3.x及最新版本的源码:https://github.com/python/cpython python2.7分支的源码:https://github.com/python/c ...

  3. 新手入门C语言第十章:C作用域规则

    C 作用域规则任何一种编程中,作用域是程序中定义的变量所存在的区域,超过该区域变量就不能被访问.C 语言中有三个地方可以声明变量: 在函数或块内部的局部变量 在所有函数外部的全局变量 在形式参数的函数 ...

  4. 我用 CSS3 实现了一个超炫的 3D 加载动画

    今天给大家带来一个非常炫酷的CSS3加载Loading动画,它的特别之处在于,整个Loading动画呈现出了3D的视觉效果.这个Loading加载动画由12个3D圆柱体围成一个椭圆形,同时这12个圆柱 ...

  5. Quantexa CDI(场景决策智能)Syneo平台介绍

    Quantexa 大数据服务提供商, 使用实体解析, 关系分析和人工智能技术帮助客户进行数据处理和预防金融犯罪. 企业概览 2016年成立, 当前规模500人 服务特色是场景决策智能CDI(conte ...

  6. FreeRTOS --(13)任务管理之空闲任务

    转载自 https://blog.csdn.net/zhoutaopower/article/details/107180016 创建完毕任务,启动调度器,任务控制,系统 SysTick 来临后判断是 ...

  7. FreeRTOS --(0)简介

    转载自https://blog.csdn.net/zhoutaopower/article/details/106541595 FreeRTOS 是一个嵌入式实时操作系统,具有相对(相对 Linux. ...

  8. 面试必问的8个CSS响应式单位,你知道几个?

    大家好,我是半夏,一个刚刚开始写文的沙雕程序员.如果喜欢我的文章,可以关注 点赞 加我微信:frontendpicker,一起学习交流前端,成为更优秀的工程师-关注公众号:搞前端的半夏,了解更多前端知 ...

  9. 【论文笔记】Federated Learning for Wireless Communications: Motivation, Opportunities, and Challenges(综述)

    Federated Learning for Wireless Communications: Motivation, Opportunities, and Challenges Authors So ...

  10. NFS学习笔记

    一.NFS原理 ## 本次实验以CentOS7.7为例 [root@qll251 ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 ( ...