赞
踩
创建springboot项目添加相关依赖。
- <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>
- <scope>test</scope>
- </dependency>
- <!-- flowable依赖包 springboot3以上需要使用7的版本 -->
- <dependency>
- <groupId>org.flowable</groupId>
- <artifactId>flowable-spring-boot-starter</artifactId>
- <version>7.0.1</version>
- </dependency>
-
-
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>8.0.33</version>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.2.20</version>
- </dependency>
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- <scope>annotationProcessor</scope>
- </dependency>
-
- <!-- 日志相关 -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>2.0.13</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-reload4j</artifactId>
- <version>2.0.13</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>

在application.yml中添加相关配置。
- spring:
- application:
- name: flowable-demo2
-
- datasource:
- driver-class-name: com.mysql.cj.jdbc.Driver
- # nullCatalogMeansCurrent=true 自动创建流程相关表
- url: jdbc:mysql://localhost:3306/flowable?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&nullCatalogMeansCurrent=true
- username: root
- password: root
- type: com.alibaba.druid.pool.DruidDataSource
-
- # flowable相关表
- flowable:
- # true 会对数据库中所有表进行更新操作。如果表不存在,则自动创建(建议开发时使用)
- database-schema-update: true
- # 关闭定时任务JOB
- async-executor-activate: false
-
- server:
- port: 8081
- logging:
- level:
- org:
- flowable: debug

选择建模器应用程序
选择要导出的建模
点击导出按钮。
将导出的文件复制到项目中。
编写测试代码。
- package org.example.flowabledemo2;
-
- import org.flowable.engine.ProcessEngine;
- import org.flowable.engine.RepositoryService;
- import org.flowable.engine.repository.Deployment;
- import org.flowable.engine.repository.DeploymentBuilder;
- import org.junit.jupiter.api.Test;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
-
- @SpringBootTest
- class FlowableDemo2ApplicationTests {
- // 提供对所有公开BPM和工作流操作的服务的访问。
- @Autowired
- private ProcessEngine processEngine;
- // 提供对流程定义和部署的存储库的访问。
- @Autowired
- private RepositoryService repositoryService;
-
- @Test
- void contextLoads() {
- // RepositoryService repositoryService1 = processEngine.getRepositoryService();
- DeploymentBuilder deployment = repositoryService.createDeployment();
- deployment.addClasspathResource("process01/FirstFlow.bpmn20.xml");
- deployment.name("第一个流程图");
- Deployment deploy = deployment.deploy();
- System.out.println("deploy.getId() = " + deploy.getId());
- }
- }

运行并打印流程ID。
在数据库中找到对应的流程定义信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。