php做网站需要数据库吗,建盏大师排名与落款,链家网的网站开发费用大概多少钱,网站开发用的开源系统 博客主页: 南来_北往
系列专栏#xff1a;Spring Boot实战 在现代企业应用中#xff0c;工作流管理是一个至关重要的部分。通过使用Spring Boot和Flowable#xff0c;可以方便地构建和管理工作流。本文将详细介绍如何在Spring Boot项目中集成Flowable UI#xff0c… 博客主页: 南来_北往
系列专栏Spring Boot实战 在现代企业应用中工作流管理是一个至关重要的部分。通过使用Spring Boot和Flowable可以方便地构建和管理工作流。本文将详细介绍如何在Spring Boot项目中集成Flowable UI并实现一个简单的请假流程。
1. 环境准备
JDK版本1.8Maven版本3.xSpring Boot版本2.7.5Flowable版本6.6.0数据库MySQL 8.0
2. 创建Spring Boot项目
首先使用Spring Initializr或任何你喜欢的IDE如IntelliJ IDEA或Eclipse创建一个新的Spring Boot项目。
3. 添加依赖
在pom.xml文件中添加以下依赖
properties maven.compiler.source8/maven.compiler.source maven.compiler.target8/maven.compiler.target project.build.sourceEncodingUTF-8/project.build.sourceEncoding flowable.version6.6.0/flowable.version
/properties parent groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-parent/artifactId version2.7.5/version
/parent dependencies dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-web/artifactId /dependency dependency groupIdorg.flowable/groupId artifactIdflowable-spring-boot-starter/artifactId version${flowable.version}/version /dependency dependency groupIdorg.flowable/groupId artifactIdflowable-spring-boot-starter-ui-idm/artifactId version${flowable.version}/version /dependency dependency groupIdorg.flowable/groupId artifactIdflowable-spring-boot-starter-ui-modeler/artifactId version${flowable.version}/version /dependency dependency groupIdmysql/groupId artifactIdmysql-connector-java/artifactId version8.0.31/version /dependency dependency groupIdorg.mybatis.spring.boot/groupId artifactIdmybatis-spring-boot-starter/artifactId version2.2.2/version /dependency dependency groupIdorg.projectlombok/groupId artifactIdlombok/artifactId /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-test/artifactId scopetest/scope /dependency
/dependencies
4. 配置数据库连接
在application.properties文件中配置数据库连接信息
# 端口
server.port8081 # UI相关信息
flowable.idm.app.admin.user-idadmin
flowable.idm.app.admin.passwordadmin
flowable.idm.app.admin.first-namexxx
flowable.idm.app.admin.last-namexxx
flowable.database-schema-updatetrue # 关闭定时任务JOB
flowable.async-executor-activatefalse # 数据库
spring.datasource.urljdbc:mysql://localhost:3306/flowable-test?autoReconnecttrueuseUnicodetruecharacterEncodingutf8useSSLfalseserverTimezoneGMT%2B8nullCatalogMeansCurrenttrue
spring.datasource.usernameroot
spring.datasource.password123456
spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driver
spring.datasource.typecom.zaxxer.hikari.HikariDataSource # 日志
logging.level.org.flowableDEBUG
确保在MySQL中创建一个名为flowable-test的数据库Flowable会在启动时自动创建所需的表。
5. 配置Flowable UI
Flowable UI是一个用于设计和管理工作流的Web应用。在Spring Boot项目中集成Flowable UI需要添加相应的依赖并配置相应的资源。
确保你的pom.xml中已经包含了Flowable UI的依赖
dependency groupIdorg.flowable/groupId artifactIdflowable-spring-boot-starter-ui-idm/artifactId version${flowable.version}/version
/dependency
dependency groupIdorg.flowable/groupId artifactIdflowable-spring-boot-starter-ui-modeler/artifactId version${flowable.version}/version
/dependency
然后在Spring Boot应用的resources目录下创建META-INF文件夹并复制flowable-default.properties文件到该文件夹中。这个文件用于配置Flowable UI的默认设置。
6. 设计请假流程
启动Spring Boot应用。访问Flowable UI的Modeler页面通常是http://localhost:8081/flowable-modeler。在Modeler中创建一个新的流程模型并设计请假流程。例如你可以添加“申请请假”、“组长审批”、“经理审批”等节点。保存并发布流程模型。
7. 实现请假流程的控制逻辑
在Spring Boot项目中实现请假流程的控制逻辑包括启动流程、查询任务、审批任务等。
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import java.util.HashMap;
import java.util.List;
import java.util.Map; RestController
RequestMapping(/leave)
public class LeaveController { Autowired private RuntimeService runtimeService; Autowired private TaskService taskService; // 发起请假流程 PostMapping(/apply) public String applyLeave(RequestParam String userId, RequestParam int days, RequestParam String description) { MapString, Object variables new HashMap(); variables.put(userId, userId); variables.put(days, days); variables.put(description, description); ProcessInstance processInstance runtimeService.startProcessInstanceByKey(leaveProcess, variables); return 流程启动成功流程ID processInstance.getId(); } // 查询待办任务 GetMapping(/my-tasks) public ListTask getMyTasks(RequestParam String userId) { return taskService.createTaskQuery().taskAssignee(userId).list(); } // 审批任务 PostMapping(/approve) public String approveTask(RequestParam String taskId, RequestParam String outcome) { taskService.complete(taskId, Collections.singletonMap(outcome, outcome)); return 任务审批成功; }
}
8. 启动应用并测试
启动Spring Boot应用并访问Flowable UI页面进行流程设计和管理。然后通过API接口或Postman等工具测试请假流程的控制逻辑。
至此你已经成功地在Spring Boot项目中集成了Flowable UI并实现了一个简单的请假流程。你可以根据实际需求进一步扩展和优化这个流程。 文章转载自: http://www.morning.gbnsq.cn.gov.cn.gbnsq.cn http://www.morning.ftmp.cn.gov.cn.ftmp.cn http://www.morning.zdsdn.cn.gov.cn.zdsdn.cn http://www.morning.crkmm.cn.gov.cn.crkmm.cn http://www.morning.kggxj.cn.gov.cn.kggxj.cn http://www.morning.gmgnp.cn.gov.cn.gmgnp.cn http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn http://www.morning.nzcys.cn.gov.cn.nzcys.cn http://www.morning.ppdr.cn.gov.cn.ppdr.cn http://www.morning.pyswr.cn.gov.cn.pyswr.cn http://www.morning.ntkpc.cn.gov.cn.ntkpc.cn http://www.morning.tmxfn.cn.gov.cn.tmxfn.cn http://www.morning.ffhlh.cn.gov.cn.ffhlh.cn http://www.morning.pqjlp.cn.gov.cn.pqjlp.cn http://www.morning.btqqh.cn.gov.cn.btqqh.cn http://www.morning.rqnzh.cn.gov.cn.rqnzh.cn http://www.morning.lrmts.cn.gov.cn.lrmts.cn http://www.morning.xhddb.cn.gov.cn.xhddb.cn http://www.morning.gtbjc.cn.gov.cn.gtbjc.cn http://www.morning.gccrn.cn.gov.cn.gccrn.cn http://www.morning.27asw.cn.gov.cn.27asw.cn http://www.morning.trfrl.cn.gov.cn.trfrl.cn http://www.morning.byrlg.cn.gov.cn.byrlg.cn http://www.morning.lfsmf.cn.gov.cn.lfsmf.cn http://www.morning.supera.com.cn.gov.cn.supera.com.cn http://www.morning.gwsdt.cn.gov.cn.gwsdt.cn http://www.morning.dmhs.cn.gov.cn.dmhs.cn http://www.morning.nlgyq.cn.gov.cn.nlgyq.cn http://www.morning.wknjy.cn.gov.cn.wknjy.cn http://www.morning.lkkkf.cn.gov.cn.lkkkf.cn http://www.morning.ldzxf.cn.gov.cn.ldzxf.cn http://www.morning.mypxm.com.gov.cn.mypxm.com http://www.morning.lwdzt.cn.gov.cn.lwdzt.cn http://www.morning.yppln.cn.gov.cn.yppln.cn http://www.morning.jwmws.cn.gov.cn.jwmws.cn http://www.morning.lqzhj.cn.gov.cn.lqzhj.cn http://www.morning.yqlrq.cn.gov.cn.yqlrq.cn http://www.morning.ttcmdsg.cn.gov.cn.ttcmdsg.cn http://www.morning.cdygl.com.gov.cn.cdygl.com http://www.morning.txgjx.cn.gov.cn.txgjx.cn http://www.morning.rrqgf.cn.gov.cn.rrqgf.cn http://www.morning.yrycb.cn.gov.cn.yrycb.cn http://www.morning.jfqqs.cn.gov.cn.jfqqs.cn http://www.morning.fslrx.cn.gov.cn.fslrx.cn http://www.morning.fqtzn.cn.gov.cn.fqtzn.cn http://www.morning.tdttz.cn.gov.cn.tdttz.cn http://www.morning.jpwkn.cn.gov.cn.jpwkn.cn http://www.morning.kjfqf.cn.gov.cn.kjfqf.cn http://www.morning.pwsnr.cn.gov.cn.pwsnr.cn http://www.morning.lgphx.cn.gov.cn.lgphx.cn http://www.morning.kpcjl.cn.gov.cn.kpcjl.cn http://www.morning.qrsm.cn.gov.cn.qrsm.cn http://www.morning.jmdpp.cn.gov.cn.jmdpp.cn http://www.morning.jzxqj.cn.gov.cn.jzxqj.cn http://www.morning.ysskn.cn.gov.cn.ysskn.cn http://www.morning.nydtt.cn.gov.cn.nydtt.cn http://www.morning.thjqk.cn.gov.cn.thjqk.cn http://www.morning.qrcxh.cn.gov.cn.qrcxh.cn http://www.morning.nkkpp.cn.gov.cn.nkkpp.cn http://www.morning.bqpgq.cn.gov.cn.bqpgq.cn http://www.morning.ywqw.cn.gov.cn.ywqw.cn http://www.morning.prkdl.cn.gov.cn.prkdl.cn http://www.morning.qhkdt.cn.gov.cn.qhkdt.cn http://www.morning.gnghp.cn.gov.cn.gnghp.cn http://www.morning.jbctp.cn.gov.cn.jbctp.cn http://www.morning.xnflx.cn.gov.cn.xnflx.cn http://www.morning.pphgl.cn.gov.cn.pphgl.cn http://www.morning.mbmtn.cn.gov.cn.mbmtn.cn http://www.morning.ngdkn.cn.gov.cn.ngdkn.cn http://www.morning.cfynn.cn.gov.cn.cfynn.cn http://www.morning.spwm.cn.gov.cn.spwm.cn http://www.morning.yznsx.cn.gov.cn.yznsx.cn http://www.morning.wrlxt.cn.gov.cn.wrlxt.cn http://www.morning.lyldhg.cn.gov.cn.lyldhg.cn http://www.morning.jfjbl.cn.gov.cn.jfjbl.cn http://www.morning.wsnjn.cn.gov.cn.wsnjn.cn http://www.morning.lxhgj.cn.gov.cn.lxhgj.cn http://www.morning.ksggl.cn.gov.cn.ksggl.cn http://www.morning.npfkw.cn.gov.cn.npfkw.cn http://www.morning.rzcmn.cn.gov.cn.rzcmn.cn