1. 下载activiti插件(我用的是eclipse开发工具)
新建项目时出现上面的就证明安装成功了,这里不具体记录了;安装成功就可以画流程图了;
2. 打开已有的项目,在pom.xml中添加activiti依赖jar包;
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
</dependency>
3. 配置数据源及activiti配置(在yml文件中)如下:
#配置数据源的属性
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/jtts?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&nullCatalogMeansCurrent=true&autoReconnect=true
username: root
password: root
max-active: 20
max-wait: 5000
initial-size: 1
filters: stat,log4j,wall
validationQuery: SELECT 'x' #验证连接
enable: true
# activiti 流程控制默认配置
activiti:
check-process-definitions: true #自动检查,部署流程定义文件
database-schema-update: true #自动更新数据库结构
process-definition-location-prefix: classpath:/processes/ #流程定义文件存放目录
4. 在启动类中springbootApplication()加入这句:是排除掉这个类的意思;
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
@MapperScan(basePackages= {"com.jtts.*.mapper"})
public class ChangKuApplication {
public static void main(String[] args) {
SpringApplication.run(ChangKuApplication.class, args);
}
5. 在项目中添加,画流程图
**
问题:
**
启动springboot项目,启动不成功,报错:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-12-23 23:05:45.302 ERROR 19168 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:369)
原因: 主要是jar包版本冲突.(activiti6.0.0版本与mybatisplus3.2.0版本冲突)
因为: mybatisPlus我用的是3.2.0,而activiti用的是mybatis3.4.2,两边有冲突。
解决办法就是去除mybatis,如下:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>6.0.0</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>
重新启动成功了,登录数据库发现了28个表;OK;
springboot2与activiti6之间也有很多坑,遇到了在记录一下;