Backend Development 15 min read

Building a Leave‑Approval Workflow with Flowable UI and Spring Boot

This article demonstrates how to deploy Flowable‑UI, design a BPMN leave‑approval process, configure a Spring Boot backend, explain Flowable database tables, and use the Flowable engine APIs with complete Java code examples to run and manage the workflow.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Building a Leave‑Approval Workflow with Flowable UI and Spring Boot

Overview

Use Flowable's built‑in Flowable‑UI to create a BPMN diagram and develop Spring Boot interfaces to implement the workflow business logic.

1. Deploy Flowable‑UI

Download https://github.com/flowable/flowable-engine/releases/download/flowable-6.6.0/flowable-6.6.0.zip , extract flowable-6.6.0\wars\flowable-ui.war , deploy it to Tomcat, and access http://localhost:8080/flowable-ui with the default admin/test credentials.

Configure the database connection in apache‑tomcat-9.0.37\webapps\flowable-ui\WEB-INF\classes\flowable-default.properties and copy the MySQL driver mysql-connector-java-5.1.45.jar to apache‑tomcat-9.0.37\webapps\flowable-rest\WEB-INF\lib .

2. Design the Process Diagram

In Flowable‑UI → APP.MODELER draw the leave‑approval flow using events, sequence flows, gateways, and user tasks. Export the BPMN XML for later use.

3. Backend Project Setup

Create a Spring Boot (JDK 8) project with the following Maven dependencies:

org.flowable
flowable-spring-boot-starter
6.6.0
mysql
mysql-connector-java
5.1.45

Configure the datasource in application.yml :

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/flowable?useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: 123456

4. Flowable Database Tables

Tables are prefixed with ACT_ and divided into repository (RE), runtime (RU), history (HI), and generic (GE) groups. The article lists the most important tables for each group, such as ACT_RE_PROCDEF , ACT_RU_TASK , and ACT_HI_PROCINST .

5. Engine API & Services

Key services include RepositoryService (deployments and definitions), RuntimeService (start instances), IdentityService (manage users/groups), TaskService (claim/complete tasks), and HistoryService (query completed data).

Code Example

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.idm.api.Group;
import org.flowable.idm.api.User;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipInputStream;

@Slf4j
public class TestFlowable {
    @Autowired private RepositoryService repositoryService;
    @Autowired private RuntimeService runtimeService;
    @Autowired private HistoryService historyService;
    @Autowired private org.flowable.engine.TaskService taskService;
    @Autowired private org.flowable.engine.IdentityService identityService;

    public void createDeploymentZip() {
        try {
            File zipTemp = new File("f:/leave_approval.bpmn20.zip");
            ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipTemp));
            Deployment deployment = repositoryService.createDeployment()
                .addZipInputStream(zipInputStream)
                .deploy();
            log.info("部署成功:{}", deployment.getId());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        // ... (rest of the steps: query definitions, start process, claim/complete tasks, query history)
    }
}

6. References

Flowable documentation (Chinese translation)

Official Flowable‑6.6.0 demo

Various blog posts on Flowable usage

JavaworkflowBPMNSpring BootFlowable
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.