一:pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>springboot-flowable</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-flowable</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<slf4j.version>1.6.6</slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- 排除自带的logback依赖 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.18</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
注意:SpringBoot的有些版本会报错FlowableException: Error initialising dmn data model
二:application.yml
如果时间少8个小时检查时区配置。
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/flowable660?serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root
password: root123
druid:
# 初始化连接数量
initial-size: 5
# 最小线连接数量
min-idle: 5
# 最大连接数量
max-active: 20
# 获取连接时最大等待时间,单位毫秒
max-wait: 60000
#销毁线程时检测当前连接的最后活动时间和当前时间差大于该值时,关闭当前连接
min-evictable-idle-time-millis: 30000
#用来检测连接是否有效的sql 必须是一个查询语句
#mysql中为 select 'x'
#oracle中为 select 1 from dual
validation-query: select 'x'
#申请连接时会执行validationQuery检测连接是否有效,开启会降低性能,默认为true
test-on-borrow: false
#归还连接时会执行validationQuery检测连接是否有效,开启会降低性能,默认为tru
test-on-return: false
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
# 配置监拉统计挡成的filters. stat: 监控统计、Log4j:日志记录、waLL: 防御sqL注入
filters: stat,wall,log4j2
# 配置后台监控
stat-view-servlet:
# 允许访问的地址,这里因为时本地所以配置当前机器
allow: 127.0.0.1
# 是否开启访问
enabled: true
# 是否能够重置数据
reset-enable: false
# 管理页面登陆的用户名
login-username: admin
# 管理页面登陆的密码
login-password: admin
flowable:
# 开启定时任务Job
async-executor-activate: true
# 是否自动更新表结构
database-schema-update: true
logging:
level:
org.flowable: trace
三:Test
@SpringBootTest
class SpringbootFlowableApplicationTests {
@Autowired
private IdentityService identityService;
@Test
void contextLoads() {
User user = identityService.newUser("huihui");
user.setFirstName("li");
user.setLastName("hui");
user.setEmail("huihui@163.com");
user.setPassword("123456");
user.setDisplayName("会会");
identityService.saveUser(user);
}
}
==> Preparing: insert into ACT_ID_USER (ID_, REV_, FIRST_, LAST_, DISPLAY_NAME_, EMAIL_, TENANT_ID_, PWD_) values ( ?, 1, ?, ?, ?, ?, ?, ? )
==> Parameters: huihui(String), li(String), hui(String), 会会(String), huihui@163.com(String), null, 123456(String)
相关常识