-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Spring Boot 2.x整合Activiti工作流以及模型设计器
Exrick edited this page Apr 13, 2019
·
1 revision
集成Activiti 5.22,考虑到文档资料较多未选用新版本(模型设计器改动较大)或Flowable
- 添加依赖,因项目已使用Mybatis-Plus,需在这里排除其mybatis依赖
<!-- Activiti -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>5.22.0</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Activiti流程图 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-diagram-rest</artifactId>
<version>5.22.0</version>
</dependency>
<!-- Activiti在线设计 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-modeler</artifactId>
<version>5.22.0</version>
</dependency>
- 入口类排除Activiti的Security校验
// Activiti5.22需要排除Security
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class XbootApplication {
public static void main(String[] args) {
SpringApplication.run(XbootApplication.class, args);
}
}
- 配置参考
# 工作流
spring:
activiti:
check-process-definitions: false
db-identity-used: true
# 自动生成Activiti相关表 第一次生成后建议关闭提高运行速度
database-schema-update: true
# 保存历史数据级别设置为full最高级别,便于历史数据的追溯
history-level: full
- 下载Activiti 5.22源码Source Code https://github.com/Activiti/Activiti/tree/activiti-5.22.0 https://github.com/Activiti/Activiti/releases/tag/activiti-5.22.0 -> https://github.com/Activiti/Activiti/archive/activiti-5.22.0.zip
- 进入modules目录,拷贝图中圈出所需文件 https://github.com/Activiti/Activiti/tree/activiti-5.22.0/modules
- 其中
stencilset.json
可到网上找汉化版本替换,并确认该文件是否放到了resources目录下,如果不是需要修改StencilsetRestResource.java
中"stencilset.json"为"xxx/stencilset.json",因此按上图配置此处需替换为InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("static/stencilset.json");
- 修改
StencilsetRestResource.java
、ModelEditorJsonRestResource.java
、ModelSaveRestResource.java
就是接口的请求路径前缀,加上@RequestMapping("xxx"),XBoot中为/xboot/act
- 接着修改对应
app-cfg.js
ACTIVITI.CONFIG = {'contextRoot' : '/xboot/act', };
- 修改
JsonpCallbackFilte.java
,加上@WebFilter("/xxx/*")
,XBoot中为@WebFilter("/xboot/act/*")
-
ModelSaveRestResource.java
参数修改
public void saveModel(@PathVariable String modelId,
@RequestParam String name, @RequestParam String description,
@RequestParam String json_xml, @RequestParam String svg_xml)
- 测试访问 localhost:8888/modeler.html?modelId=1会出现空白页,集成成功。由于modelId=1随意输入,后台并无id=1的数据,所以报错,具体新建一个模型的接口自行百度即可,当然也可付费获取完整版。