SpringBoot-整合Activiti7
参考文献
环境配置
-
框架版本
- SpringBoot 2.5.7
- SpringCloud 2020.0.3
- activiti 7.1.0.M6
- flyway 8.0.5
- mysql 8.0.27
-
依赖信息
-
build.gradle
配置(修改后的)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
97buildscript {
ext {
springBootVersion = '2.5.7'
springCloudVersion = '2020.0.3'
activitiVersion = "7.1.0.M6"
hutoolVersion = "5.7.16"
flywayVersion = "8.0.5"
mysqlVerssion = "8.0.27"
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:1.0.10.RELEASE"
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "1.4.31"
id "application"
}
group "com.xxxx.xxxx"
version "1.0-SNAPSHOT"
configurations {
ktlint
runtime.exclude group: "org.slf4j", module: "slf4j-log4j12"
}
repositories {
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
mavenCentral()
}
dependencies {
implementation platform("org.jetbrains.kotlin:kotlin-bom")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "com.google.guava:guava:30.1-jre"
implementation "org.jetbrains.kotlin:kotlin-reflect"
// SpringBoot
implementation("org.springframework.boot:spring-boot-starter:$springBootVersion")
implementation("org.springframework.boot:spring-boot-starter-web:$springBootVersion") {
exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat"
}
implementation("org.springframework.boot:spring-boot-starter-jetty:$springBootVersion")
implementation("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
implementation("org.springframework.boot:spring-boot-actuator-autoconfigure:$springBootVersion")
// 数据库相关
implementation("org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion")
implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
implementation "mysql:mysql-connector-java:$mysqlVerssion"
// 数据库脚本管理框架
implementation("org.flywaydb:flyway-core:$flywayVersion")
// MQ
implementation("org.springframework.boot:spring-boot-starter-amqp:$springBootVersion")
// Redis
implementation("org.springframework.boot:spring-boot-starter-data-redis:$springBootVersion")
// SpringCloud
compile("org.springframework.cloud:spring-cloud-starter-config")
compile("org.springframework.cloud:spring-cloud-starter-consul-discovery")
compile("org.springframework.cloud:spring-cloud-starter-openfeign")
implementation("org.springframework.cloud:spring-cloud-starter-bootstrap:3.0.4")
// 工作流引擎starter
implementation("org.activiti:activiti-spring-boot-starter:$activitiVersion")
// 工具类
implementation("cn.hutool:hutool-core:$hutoolVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.0")
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
}
apply plugin: "io.spring.dependency-management"
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
application {
mainClass = "com.dianeiai.hemnes.AppKt"
}
compileKotlin {
kotlinOptions.jvmTarget = "11"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "11"
} -
maven
配置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
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.holelin</groupId>
<artifactId>business-automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.holelin</groupId>
<artifactId>activiti</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>activiti</name>
<description>activiti</description>
<properties>
<java.version>11</java.version>
<activiti.version>7.1.0.M6</activiti.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<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>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>${activiti.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
-
遇到的问题
Table ‘xxx.act_ge_property’ doesn’t exist
1 | Caused by: org.apache.ibatis.exceptions.PersistenceException: |
-
解决方法: 在
spring.datasource.url
补充nullCatalogMeansCurrent=true
1
2
3spring:
datasource:
url: jdbc:mysql://localhost:3306/hemnes?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
Consider revisiting the entries above or defining a bean of type ‘javax.sql.DataSource’ in your configuration
1 | Description: |
-
原因: 缺少默认DataSource数据源
-
解决方法:
-
添加
JPA
/MyBatis
等数据库的starter
1
implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
-
No spring.config.import property has been defined
1 | No spring.config.import property has been defined |
-
解决方法
1
2
3
4<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>1
implementation("org.springframework.cloud:spring-cloud-starter-bootstrap:3.0.4")
Activiti使用注意点
-
在使用
UserTask
的TaskListener
来对UserTask
任务进行监听时,若要使用Spring的自动注入功能,需要在配置监听器的时候使用delegateExpression
来指定,如下所示:1
2
3
4
5
6
7
8<bpmn:userTask id="xxxxx" name="xxxx">
<bpmn:extensionElements>
<activiti:taskListener event="create" delegateExpression="${createListener}"/>
<activiti:taskListener event="complete" delegateExpression="${completeListener}"/>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1chtlxm</bpmn:incoming>
<bpmn:outgoing>Flow_0n355t9</bpmn:outgoing>
</bpmn:userTask>
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 HoleLin's Blog!