下面就直接上一个最简单的示例程序作为入门。
需求:
主要注意和camunda相关的4个应用,
<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.0modelVersion>
<groupId>com.b5wang.cloudlab.bpmgroupId>
<artifactId>camundaexartifactId>
<version>0.1-SNAPSHOTversion>
<packaging>jarpackaging>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<maven.compiler.source>1.8maven.compiler.source>
<maven.compiler.target>1.8maven.compiler.target>
<spring-boot.version>2.7.8spring-boot.version>
<spring-cloud.version>2022.0.0spring-cloud.version>
<log4j-1.2-api.version>2.13.3log4j-1.2-api.version>
<camunda.version>7.18.0camunda.version>
properties>
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
dependency>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
<exclusions>
<exclusion>
<groupId>org.junit.vintagegroupId>
<artifactId>junit-vintage-engineartifactId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-jdbcartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-jpaartifactId>
dependency>
<dependency>
<groupId>com.mysqlgroupId>
<artifactId>mysql-connector-jartifactId>
<version>8.0.32version>
dependency>
<dependency>
<groupId>org.camunda.bpm.springbootgroupId>
<artifactId>camunda-bpm-spring-boot-starterartifactId>
dependency>
<dependency>
<groupId>org.camunda.bpm.springbootgroupId>
<artifactId>camunda-bpm-spring-boot-starter-restartifactId>
dependency>
<dependency>
<groupId>org.camunda.bpm.springbootgroupId>
<artifactId>camunda-bpm-spring-boot-starter-webappartifactId>
dependency>
<dependency>
<groupId>org.camunda.bpm.springbootgroupId>
<artifactId>camunda-bpm-spring-boot-starter-external-task-clientartifactId>
dependency>
dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-dependenciesartifactId>
<version>${spring-boot.version}version>
<type>pomtype>
<scope>importscope>
dependency>
<dependency>
<groupId>org.springframework.cloudgroupId>
<artifactId>spring-cloud-dependenciesartifactId>
<version>${spring-cloud.version}version>
<type>pomtype>
<scope>importscope>
dependency>
<dependency>
<groupId>org.camunda.bpmgroupId>
<artifactId>camunda-bomartifactId>
<version>${camunda.version}version>
<type>pomtype>
<scope>importscope>
dependency>
dependencies>
dependencyManagement>
<build>
<finalName>${project.artifactId}finalName>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-site-pluginartifactId>
<version>3.8.2version>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-project-info-reports-pluginartifactId>
<version>3.0.0version>
plugin>
plugins>
build>
project>
server:
port: 9090
spring:
application:
name: camundaex
# 数据库配置
datasource:
type: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/camundaex?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: 111
# Hikari 连接池配置
hikari:
# 最小空闲连接数量
minimum-idle: 5
# 空闲连接存活最大时间,默认600000(10分钟)
idle-timeout: 180000
# 连接池最大连接数,默认是10
maximum-pool-size: 10
# 此属性控制从池返回的连接的默认自动提交行为,默认值:true
auto-commit: true
# 连接池名称
pool-name: HK-CP
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
max-lifetime: 1800000
# 数据库连接超时时间,默认30秒,即30000
connection-timeout: 30000
connection-test-query: SELECT 1
logging:
level:
com.zaxxer.hikari.HikariConfig: DEBUG
com.zaxxer.hikari: TRACE
# camunda configuration
camunda.bpm:
# 第一次启动时创建管理员
admin-user:
id: camunda
password: camunda
firstName: Camunda
filter:
create: All tasks
文件路径:resources/META-INF/processes.xml
<process-application
xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<process-archive name="camunda-process-engine">
<process-engine>defaultprocess-engine>
<properties>
<property name="isDeleteUponUndeploy">falseproperty>
<property name="isScanForProcessDefinitions">trueproperty>
properties>
process-archive>
process-application>
import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableProcessApplication
public class AppStarter {
public static void main(String[] args){
SpringApplication.run(AppStarter.class,args);
}
}
mysql创建一个空的schema, camundaex
drop schema if exists camundaex;
create schema if not exists camundaex;
检查两个结果:
本文的源码:https://github.com/b5wang/cloudlab/tree/master/bpm/camundaex
Camunda入门(一) - 选型及核心概念
Camunda入门(二) - 启动Camunda管理平台
Camunda入门(三) - BPMN、DMN、Form相关模型介绍(持续补充…)
Camunda入门(四) - 流程应用(支付流程)入门示例
示例代码
http://camunda-cn.shaochenfeng.com/
https://docs.camunda.org/get-started/
https://docs.camunda.io/
https://camunda.com/
https://camunda.com/download/