BPMN 2.0 - Activiti Setup

项目需要, 需要将BPMN 2.0应用到项目中. 参考了下现有的BPMN 2.0标准的一些现有在流行的框架技术, 选择了 Activiti 进行学习.

项目构建

spring-boot加上Activiti构建项目

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-jpa</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.activiti</groupId>-->
<!--<artifactId>activiti-spring-boot-starter-rest-api</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-actuator</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.h2database</groupId>-->
<!--<artifactId>h2</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>${activiti.version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-jpa</artifactId>
<version>${activiti.version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-rest-api</artifactId>
<!--<artifactId>spring-boot-starter-rest-api</artifactId>-->
<version>${activiti.version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-actuator</artifactId>
<version>${activiti.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
<version>1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>

<activiti.version>6.0.0</activiti.version>

<test.db.host>localhost</test.db.host>
<test.db.port>3306</test.db.port>
<test.db.name>bpmn_demo_v1</test.db.name>
<test.db.username>root</test.db.username>
<test.db.password>password</test.db.password>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

数据源配置 (application.yml):

1
2
3
4
5
6
7
8
9
10
11
spring:
jpa:
hibernate:
ddl-auto: update

datasource:
url: jdbc:mysql://@test.db.host@:@test.db.port@/@test.db.name@?createDatabaseIfNotExist=true
driver-class-name: com.mysql.jdbc.Driver
username: @test.db.username@
password: @test.db.password@
`

Java Config项目配置

1
2
3
4
5
6
7
@ComponentScan({ "org.wangy.bpmn.demo.v1.service", "org.wangy.bpmn.demo.v1.controller" })
@Configuration
@EnableJpaRepositories("org.wangy.bpmn.demo.v1.repository")
@EntityScan("org.wangy.bpmn.demo.v1.domain")
public class LaunchConfig {
...
}

接下来, 我们通过一些例子来测试工作流

- [动态发布工作流](./activiti-dynamic-deploy.md)
- [动态分配流程任务执行人](./activiti-dynamic-assignee.md)