工作流Flowable官网demo运行记录

本文详细介绍如何下载并安装 Flowable 6.5.0 版本,包括配置 MySQL 数据库连接及使用 Tomcat 启动的具体步骤。

几番折腾,终于启动了,请支持原创,请勿转载、爬虫;

1、在官网下载flowable 6.5.0版本即可,或者从本博客下载;
     

2、修改文件中的配置项改为自己的mysql数据库:
   a、修注释掉H2 打开mysql连接


   b、修改账号密码

       
   c、放开mysql


启动:
需使用tomcat
链接:https://pan.baidu.com/s/1lTi9WGozK3usie6-UeelFQ 
提取码:7y9w 

### Spring Boot 集成 Flowable 工作流实例教程 #### 创建 Maven 项目结构 为了创建一个新的 Maven 项目,可以利用 `maven-archetype-quickstart` 插件来快速搭建基础框架。这允许开发者专注于业务逻辑而非项目的初始设置[^2]。 ```bash mvn archetype:generate \ -DgroupId=com.example.flowabledemo \ -DartifactId=flowable-demo \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=false ``` #### 添加依赖项至 pom.xml 文件 在集成 Flowable 到 Spring Boot 中时,在 `pom.xml` 文件内加入必要的依赖库是必需的操作之一: ```xml <dependencies> <!-- Spring Boot Starter Web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- Spring Boot Starter Data JPA --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <!-- H2 Database (for demonstration purposes) --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> <!-- Flowable Spring Boot Starter --> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-spring-boot-starter</artifactId> <version>${flowable.version}</version> </dependency> <!-- Thymeleaf Template Engine --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> ``` 上述配置不仅引入了用于构建 RESTful API 和持久化数据的支持包,还包含了 Flowable 流程引擎以及模板渲染工具 Thymeleaf 的支持[^1]。 #### 启动类定义 确保应用程序启动类上标注有 `@SpringBootApplication` 注解,并且位于合适的位置以便自动扫描组件和服务层实现。 ```java package com.example.flowabledemo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` #### 定义流程模型文件 Flowable 使用 BPMN 2.0 标准描述业务过程管理中的活动序列。可以在 `src/main/resources/processes/` 路径下放置 `.bpmn20.xml` 或者其他格式的过程定义文档。 例如,一个简单的工作流可能如下所示: ```xml <?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" targetNamespace="http://www.flowable.org/processdef"> <process id="myProcess" name="My process"> <startEvent id="theStart"/> <sequenceFlow sourceRef="theStart" targetRef="taskUser"/> <userTask id="taskUser" name="A user task"/> <endEvent id="theEnd"/> </process> </definitions> ``` 此 XML 片段展示了从开始事件到结束之间经过一个人工任务节点的最简化路径。 #### 实现控制器处理 HTTP 请求并触发流程执行 通过编写 RestController 来暴露端点接口供外部调用,从而能够发起新的流程实例或是查询当前运行状态的信息。 ```java @RestController @RequestMapping("/api/workflows") class WorkflowRestController { @Autowired private RuntimeService runtimeService; @PostMapping("/start/{processDefinitionKey}") ResponseEntity<String> startProcess(@PathVariable String processDefinitionKey){ ProcessInstance pi = runtimeService.startProcessInstanceByKey(processDefinitionKey); return new ResponseEntity<>("Started process with ID " + pi.getId(), HttpStatus.CREATED); } // More endpoints... } ``` 这段代码片段提供了一个 POST 方法用来启动指定名称的关键字对应的新流程实例。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值