一、官网下载 camunda 编辑工具

官方下载地址

https://camunda.com/download/modeler/

二、下载后可以集成在 idea 中

file -> Setting -> Tools -> External Toolsf73a9555dfefaa51d0a9a9ebe72e27f9.png这里设置后,选中你放的 bpmn 文件,点击 tools ->External Tools 选中 camunda(刚刚上面自己命名的扩展工具的名字),就会打开流程图编辑页面进行操作40e027c1cdeaf2c1cddae515258f2014.pnga3bfef490ba35e9e4ada4c4fdeca0010.png

现在就可以根据前面文章写的 springboot 项目,在此配置文件基础上集成 camunda

一、添加依赖

<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
  <artifactId>camunda-bpm-spring-boot-starter</artifactId>
  <version>3.4.0</version>
</dependency>
<dependency>
  <groupId>org.camunda.bpm.springboot</groupId>
  <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
  <version>3.4.0</version>
</dependency>
<dependency>
  <groupId>org.camunda.bpm.springboot</groupId>
  <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
  <version>3.4.0</version>
</dependency>

二、设置 camunda 界面登录名和密码

application.yml:

###################
#
# camunda 登录信息设置
#
###################
camunda.bpm:
 admin-user:
  id: admin
  password: admin
  firstName: Kermit
 filter:
  create: All tasks

三、启动项目,会在原来 springboot 项目中配置的数据库中自动生成 47 张表,浏览器输入 http://localhost:1234/demo-cmf

用配置的 admin/admin 登录bfb80de900a262d5b7c8b996b7a4d713.pnge94db1b74b57eb5be2db38c9b1aa61cf.png四、发起流程 在 resource 目录下新建一个 processes 目录,放 camunda.bpmn 流程图文件 画了个很简单的图:274c7a99933b2c1077ec03f7c50e9188.png

  • 写启动和执行代码:

@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;

public void start(){
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("TaskCmf01");  //画流程图时设置的process_id
    log.info("processInstance:"+processInstance);
    if(processInstance != null){
      log.info("流程发起成功");
    }else{
      log.info("流程发起失败");
    }
  }

public void complete(String taskId){
   taskService.complete(taskId);
 }
  • 调用 start 方法后,会创建一笔流程,可以在流程图界面看见:2afbff417d2a4f27e3ad7b5717408a15.png

  • 使用上图的 taskid, 调用 complete 方法 这时代码报错了:批处理不支持1d4b80216dca40183be2e50b31b3808f.png这里搜索了很多地方,但是一直没找到原因,后续有解决方法的时候我再 更新上来。


作者:过客匆匆@1

来源链接:

https://blog.csdn.net/weixin_43779185/article/details/115867902

be7d0223cf2cfea0d219fa0d78906ada.png

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐