相关文章推荐
满身肌肉的熊猫  ·  pa-book·  7 月前    · 
自信的酱肘子  ·  Android Recycleview ...·  1 年前    · 
发呆的茴香  ·  解决eslint报错“Parsing ...·  1 年前    · 

参考: 【Camunda 一】Springboot集成Camunda使用Mysql_LoneWalker、的博客-CSDN博客_camunda springboot

一、匹配版本简介

基于Camunda 7.17.0 + Springboot 2.6.4

首先官网camunda7.17对应的springboot版本。 camunda官网

使用camunda流程引擎、web界面、Rest服务接口相应依赖如下:

  • 流程引擎:camunda-bpm-spring-boot-starter
  • Rest服务接口:camunda-bpm-spring-boot-starter-rest
  • web界面模块:camunda-bpm-spring-boot-starter-webapp
<dependency>
    <groupId>org.camunda.bpm.springboot</groupId>
    <artifactId>camunda-bpm-spring-boot-starter</artifactId>
    <version>7.17.0</version>
</dependency>
<dependency>
    <groupId>org.camunda.bpm.springboot</groupId>
    <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
    <version>7.17.0</version>
</dependency>
<dependency>
    <groupId>org.camunda.bpm.springboot</groupId>
    <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
    <version>7.17.0</version>
</dependency>

相关属性配置可参考 Springboot集成配置

二、构建SpringBoot工程

Camunda官网提供了构建SpringBoot基础工程构建界面 Camunda Platform Initializr ,在该界面配置相应的配置参数,如下图所示:

导出后,即为基础的springboot工程,默认为H2数据库配置。

三、配置MySql,Postgresql数据库

3.1 配置Mysql,Postgresql数据库时,需要首先新建相应的数据库,如下图所示:

3.2 SpringBoot pom.xml文件配置

pom文件(见3.2.4)中配置了H2, Mysql, Postgresql相应的配置,使用哪种数据库,只需要打开相应的注释即可。

3.2.1 H2 pom文件配置:

3.2.2 Mysql pom文件配置:

3.2.3 Postgresql pom文件配置

3.2.4 SpringBoot Pom文件

<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.houpe.camunda</groupId>
  <artifactId>spring-boot-camunda-demo2</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.6.4</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-bom</artifactId>
        <version>7.17.0</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
      流程引擎:camunda-bpm-spring-boot-starter
      Rest服务接口:camunda-bpm-spring-boot-starter-rest
      web界面模块:camunda-bpm-spring-boot-starter-webapp
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-plugin-spin</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.spin</groupId>
      <artifactId>camunda-spin-dataformat-all</artifactId>
    </dependency>
    <!--h2-->
    <!--<dependency>-->
    <!--  <groupId>com.h2database</groupId>-->
    <!--  <artifactId>h2</artifactId>-->
    <!--</dependency>-->
    <!--<dependency>-->
    <!--  <groupId>org.springframework.boot</groupId>-->
    <!--  <artifactId>spring-boot-starter-jdbc</artifactId>-->
    <!--</dependency>-->
    <!--mysql-->
    <!--<dependency>-->
    <!--  <groupId>mysql</groupId>-->
    <!--  <artifactId>mysql-connector-java</artifactId>-->
    <!--  <version>5.1.47</version>-->
    <!--</dependency>-->
    <!--<dependency>-->
    <!--  <groupId>org.springframework.boot</groupId>-->
    <!--  <artifactId>spring-boot-starter-jdbc</artifactId>-->
    <!--</dependency>-->
    <!--postgresql-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid-spring-boot-starter</artifactId>
      <version>1.1.21</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba.fastjson2</groupId>
      <artifactId>fastjson2</artifactId>
      <version>2.0.12</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.6.4</version>
      </plugin>
    </plugins>
  </build>
</project>

3.3 application.yaml文件

application.yaml文件中分别配置了H2, Mysql, Postgresql数据库配置,使用哪种数据库,只需要打开相应的注释即可。

#spring.datasource.url: jdbc:h2:file:./camunda-h2-database
camunda.bpm.admin-user:
  id: demo
  password: 123
server:
  port: 8100
spring:
  application:
    name: spring-boot-camunda-demo2
  datasource:
#    url: jdbc:h2:file:./camunda-h2-database
    # mysql
#    url: jdbc:mysql://39.103.217.57:3306/camunda2?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&useOldAliasMetadataBehavior=true
#    driver-class-name: com.mysql.jdbc.Driver
#    username: root
#    password: root123
    # postgresql
    url: jdbc:postgresql://39.103.217.57:15432/camunda3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&useSSL=false
    username: postgres
    password: 123abc
    type: com.alibaba.druid.pool.DruidDataSource
    initialization-mode: always

四、启动项目

直接启动项目后,就可以看到数据库已经生成了49张表:

数据库表介绍:

  • ACT_RE_*:RE代表存repository。带有此前缀的表包含“静态”信息,例如流程定义和流程资源(图像、规则等)。
  • ACT_RU_*:RU代表runtime。这些是运行时表,包含流程实例、用户任务、变量、作业等的运行时数据。引擎仅在流程实例执行期间存储运行时数据,并在流程实例结束时删除记录。这使运行时表既小又快。
  • ACT_ID_*:ID代表identity。这些表包含身份信息,例如用户、组等。
  • ACT_HI_*:HI代表history。这些是包含历史数据的表,例如过去的流程实例、变量、任务等。
  • ACT_GE_*:GE代表 general一般数据,用于各种用例

本文只集成了流程引擎。

基于Camunda 7.17.0 + Springboot 2.6.4首先官网camunda7.17对应的springboot版本。camunda官网流程引擎:camunda-bpm-spring-boot-starterRest服务接口:camunda-bpm-spring-boot-starter-restweb界面模块:camunda-bpm-spring-boot-starter-webapp相关属性配置可参考Springboot集成配置。
节点之间的参数传递 书接上回 Camunda 工作流 集成 SpringBoot (三) 业务场景:还是一条请假申请,总不能没有请假的理由,直接申请到领导那里请求领导批示吧,所以在工作流之间参数的传递怎么做呢 TaskService setVariable和setVariableLocal 区别:前者全局,后者只能本节点 使用 //如果是职员任务节点需要提交任务参数 if(task.getAssignee().equals("zhangsan")) { /** 1. 使用 基本数据类型设置流程变量
<dependency> <groupId>org. spring framework. boot </groupId> <artifactId> spring - boot -starter-data-jpa</artifactId> <optional>true</optional> </depe
Camunda 默认 使用 已预先配置好的 H2 数据库 数据库 模式和所有必需的表将在引擎第一次启动时自动创建。如果你想 使用 自定义独立 数据库 ,如何给 Camunda 配置 mysql 数据库 ,请遵循以下步骤: 一、新建 mysql 数据库 Camunda 平台创建一个 数据库 模式,名称为 camunda 715 、导入SQL脚本 执行创建所有必需的表和默认索引的SQL DDL脚本。这些脚本可以在configuration/sql/create文件夹中找到。共2个脚本,都需要导入。 导入完成后的表结构,共40张表: 三、配置数据
如果您想添加 Camunda BPM Rest API,您必须将以下依赖项添加到您的 Maven 构建中。 < dependency> < groupId>org. camunda .bpm</ groupId> < artifactId> camunda -engine-rest</ artifactId> < classifier>classes</ classifier> < version>7.2.0</ version> </ dependency> 如果它存在于类路径中,它将被自动检测并在 . 以弹簧为例 spring .datasource.url=jdbc: postgresql ://localhost:5432/dbname spring .datasource.username=username spring .datasource.password=password spring .datasource.driver-class-name=org. postgresql .Driver 其中,url中的dbname是你要连接的 数据库 名,username和password是 数据库 的用户名和密码。 3. 创建实体类和DAO 创建实体类和DAO, 使用 JPA或MyBatis等框架进行 数据库 操作。 4. 测试连接 启动应用程序,测试 数据库 连接是否成功。 以上就是 Spring Boot 集成 PostgreSQL 的基本步骤。 一定要坚持创作更多高质量博客哦, 小小红包, 以资鼓励, 更多创作活动请看: 新星计划2023: https://marketing.csdn.net/p/1738cda78d47b2ebb920916aab7c3584?utm_source=csdn_ai_ada_redpacket 上传ChatGPT/计算机论文等资源,瓜分¥5000元现金: https://blog.csdn.net/VIP_Assistant/article/details/130196121?utm_source=csdn_ai_ada_redpacket 新人首创任务挑战赛: https://marketing.csdn.net/p/90a06697f3eae83aabea1e150f5be8a5?utm_source=csdn_ai_ada_redpacket Microsoft Edge功能测评!: https://activity.csdn.net/creatActivity?id=10403?utm_source=csdn_ai_ada_redpacket 生物识别技术能否成为应对安全挑战的绝佳选择?: https://activity.csdn.net/creatActivity?id=10411?utm_source=csdn_ai_ada_redpacket 应届生如何提高职场竞争力: https://activity.csdn.net/creatActivity?id=10409?utm_source=csdn_ai_ada_redpacket 讯飞星火大模型将超越chatgpt?: https://activity.csdn.net/creatActivity?id=10407?utm_source=csdn_ai_ada_redpacket 职场新人备忘录: https://activity.csdn.net/creatActivity?id=10405?utm_source=csdn_ai_ada_redpacket “裸奔”时代下该如何保护网络隐私: https://activity.csdn.net/creatActivity?id=10401?utm_source=csdn_ai_ada_redpacket VR vs AR:哪种技术更有潜力改变未来?: https://activity.csdn.net/creatActivity?id=10399?utm_source=csdn_ai_ada_redpacket 蓝桥杯备赛指南分享: https://activity.csdn.net/creatActivity?id=10317?utm_source=csdn_ai_ada_redpacket 有哪些工具软件是一旦用了就离不开的?: https://activity.csdn.net/creatActivity?id=10397?utm_source=csdn_ai_ada_redpacket 量子计算:下一个大风口,还是一个热炒概念?: https://activity.csdn.net/creatActivity?id=10395?utm_source=csdn_ai_ada_redpacket