当前位置:   article > 正文

springboot与flowable(2):流程部署_springboot2部署flowableui创建的流程

springboot2部署flowableui创建的流程

一、创建项目

        创建springboot项目添加相关依赖。

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-web</artifactId>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-test</artifactId>
  9. <scope>test</scope>
  10. </dependency>
  11. <!-- flowable依赖包 springboot3以上需要使用7的版本 -->
  12. <dependency>
  13. <groupId>org.flowable</groupId>
  14. <artifactId>flowable-spring-boot-starter</artifactId>
  15. <version>7.0.1</version>
  16. </dependency>
  17. <dependency>
  18. <groupId>mysql</groupId>
  19. <artifactId>mysql-connector-java</artifactId>
  20. <version>8.0.33</version>
  21. </dependency>
  22. <dependency>
  23. <groupId>com.alibaba</groupId>
  24. <artifactId>druid</artifactId>
  25. <version>1.2.20</version>
  26. </dependency>
  27. <dependency>
  28. <groupId>org.projectlombok</groupId>
  29. <artifactId>lombok</artifactId>
  30. <scope>annotationProcessor</scope>
  31. </dependency>
  32. <!-- 日志相关 -->
  33. <dependency>
  34. <groupId>org.slf4j</groupId>
  35. <artifactId>slf4j-api</artifactId>
  36. <version>2.0.13</version>
  37. </dependency>
  38. <dependency>
  39. <groupId>org.slf4j</groupId>
  40. <artifactId>slf4j-reload4j</artifactId>
  41. <version>2.0.13</version>
  42. <scope>test</scope>
  43. </dependency>
  44. </dependencies>

        在application.yml中添加相关配置。

  1. spring:
  2. application:
  3. name: flowable-demo2
  4. datasource:
  5. driver-class-name: com.mysql.cj.jdbc.Driver
  6. # nullCatalogMeansCurrent=true 自动创建流程相关表
  7. url: jdbc:mysql://localhost:3306/flowable?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&nullCatalogMeansCurrent=true
  8. username: root
  9. password: root
  10. type: com.alibaba.druid.pool.DruidDataSource
  11. # flowable相关表
  12. flowable:
  13. # true 会对数据库中所有表进行更新操作。如果表不存在,则自动创建(建议开发时使用)
  14. database-schema-update: true
  15. # 关闭定时任务JOB
  16. async-executor-activate: false
  17. server:
  18. port: 8081
  19. logging:
  20. level:
  21. org:
  22. flowable: debug

二、导出流程定义

        选择建模器应用程序

        选择要导出的建模 

        点击导出按钮。 

        将导出的文件复制到项目中。

三、测试

        编写测试代码。

  1. package org.example.flowabledemo2;
  2. import org.flowable.engine.ProcessEngine;
  3. import org.flowable.engine.RepositoryService;
  4. import org.flowable.engine.repository.Deployment;
  5. import org.flowable.engine.repository.DeploymentBuilder;
  6. import org.junit.jupiter.api.Test;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.boot.test.context.SpringBootTest;
  9. @SpringBootTest
  10. class FlowableDemo2ApplicationTests {
  11. // 提供对所有公开BPM和工作流操作的服务的访问。
  12. @Autowired
  13. private ProcessEngine processEngine;
  14. // 提供对流程定义和部署的存储库的访问。
  15. @Autowired
  16. private RepositoryService repositoryService;
  17. @Test
  18. void contextLoads() {
  19. // RepositoryService repositoryService1 = processEngine.getRepositoryService();
  20. DeploymentBuilder deployment = repositoryService.createDeployment();
  21. deployment.addClasspathResource("process01/FirstFlow.bpmn20.xml");
  22. deployment.name("第一个流程图");
  23. Deployment deploy = deployment.deploy();
  24. System.out.println("deploy.getId() = " + deploy.getId());
  25. }
  26. }

        运行并打印流程ID。 

        在数据库中找到对应的流程定义信息。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/718859
推荐阅读
相关标签
  

闽ICP备14008679号