Spring Boot
Spring Boot 是一个应用框架,根据其网站的说法,它让你可以轻松创建独立的、生产级别的、可以"直接运行"的基于 Spring 的应用。它对 Spring 平台和第三方库采取约定优于配置的态度,让你以最少的麻烦开始。大多数 Spring Boot 应用只需要极少的 Spring 配置。
有关 Spring Boot 的更多信息,参见 http://projects.spring.io/spring-boot/
Spring Boot 与 Flowable 的集成是与 Spring 提交者共同开发的。
兼容性
Flowable 支持 Spring Boot 4.x。
快速开始
Spring Boot 全是关于约定优于配置。
要开始,你需要创建一个 Spring Boot 项目。
最简单的方式是通过 start.spring.io 创建项目。
例如创建一个带 web 和 h2 依赖 的项目。
然后在创建的项目中只需添加 flowable-spring-boot-starter 或 flowable-spring-boot-starter-rest 依赖。
如果你不需要所有引擎,参见其他 Flowable starters。
例如对于 Maven:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>${flowable.version}</version>
</dependency>
这就是全部所需。该依赖会传递性地把正确的 Flowable 依赖加入 classpath。
现在你可以运行 Spring Boot 应用了:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(proxyBeanMethods = false)
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
你会看到类似这样的输出:
(以下为 Spring Boot 启动横幅与控制台日志输出。)
(Spring Boot 版本行。)
(应用启动日志:显示各引擎创建、数据库建表、异步执行器启动等过程。)
因此,仅仅把依赖加入 classpath 并使用 @SpringBootApplication 注解,幕后已经完成了大量工作:
- 自动创建了一个内存数据源(因为 H2 驱动在 classpath 上)并传给 Flowable 流程引擎配置
- 创建并暴露了 Flowable ProcessEngine、CmmnEngine、DmnEngine 和 IdmEngine bean
- 所有 Flowable 服务都暴露为 Spring bean
- 创建了 Spring Job Executor
另外:
- processes 文件夹中的所有 BPMN 2.0 流程定义会自动部署。创建一个 processes 文件夹,并向其中添加一个示例流程定义(名为 one-task-process.bpmn20.xml)。该文件的内容如下所示。
- cases 文件夹中的所有 CMMN 1.1 case 定义会自动部署。
- dmn 文件夹中的所有 DMN 1.1 dmn 定义会自动部署。
流程定义的 XML 内容如下所示。注意,目前我们把用户任务的办理人硬编码为 "kermit"。稍后我们会再回到这个问题。
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">
<process id="oneTaskProcess" name="The One Task Process">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
<userTask id="theTask" name="my task" flowable:assignee="kermit" />
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
另外,添加以下代码行来测试部署是否真的生效。CommandLineRunner 是一种特殊的 Spring bean,在应用启动时执行:
@SpringBootApplication(proxyBeanMethods = false)
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Bean
public CommandLineRunner init(final RepositoryService repositoryService,
final RuntimeService runtimeService,
final TaskService taskService) {
return new CommandLineRunner() {
@Override
public void run(String... strings) throws Exception {
System.out.println("Number of process definitions : "
+ repositoryService.createProcessDefinitionQuery().count());
System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
runtimeService.startProcessInstanceByKey("oneTaskProcess");
System.out.println("Number of tasks after process start: "
+ taskService.createTaskQuery().count());
}
};
}
}
预期的输出为:
Number of process definitions : 1
Number of tasks : 0
Number of tasks after process start : 1
更换数据库与连接池
如上所述,Spring Boot 是约定优于配置。默认情况下,由于 classpath 上只有 H2,它创建了一个内存数据源并传给 Flowable 流程引擎配置。
要更换数据源,只需添加数据库驱动依赖并提供数据库 URL。
例如切换到 MySQL 数据库:
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/flowable-spring-boot?characterEncoding=UTF-8
spring.datasource.username=flowable
spring.datasource.password=flowable
从 Maven 依赖中移除 H2,并把 MySQL 驱动加入 classpath:
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.6.0</version>
</dependency>
现在启动应用时,你会看到它使用 MySQL 作为数据库(以及 HikariCP 连接池框架):
org.flowable.engine.impl.db.DbSqlSession : performing create on engine with resource org/flowable/db/create/flowable.mysql.create.engine.sql
org.flowable.engine.impl.db.DbSqlSession : performing create on history with resource org/flowable/db/create/flowable.mysql.create.history.sql
org.flowable.engine.impl.db.DbSqlSession : performing create on identity with resource org/flowable/db/create/flowable.mysql.create.identity.sql
多次重启应用后,你会看到任务数量上升(H2 内存数据库无法在关机后存活,MySQL 可以)。
有关如何配置数据源的更多信息,参见 Spring Boot 参考指南中的 Configure a DataSource。
REST 支持
通常,会在嵌入式 Flowable 引擎之上使用一个 REST API(与公司中的各种服务交互)。Spring Boot 让这变得非常简单。向 classpath 添加以下依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
创建一个新类——一个 Spring 服务,并创建两个方法:一个启动我们的流程,一个获取给定办理人的任务列表。
我们这里只是简单地包装 Flowable 调用,但在真实场景中这会更复杂。
@Service
public class MyService {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Transactional
public void startProcess() {
runtimeService.startProcessInstanceByKey("oneTaskProcess");
}
@Transactional
public List<Task> getTasks(String assignee) {
return taskService.createTaskQuery().taskAssignee(assignee).list();
}
}
现在我们可以通过用 @RestController 注解一个类来创建 REST 端点。这里我们简单地委托给上面定义的服务。
@RestController
public class MyRestController {
@Autowired
private MyService myService;
@PostMapping(value="/process")
public void startProcessInstance() {
myService.startProcess();
}
@RequestMapping(value="/tasks", method= RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
public List<TaskRepresentation> getTasks(@RequestParam String assignee) {
List<Task> tasks = myService.getTasks(assignee);
List<TaskRepresentation> dtos = new ArrayList<TaskRepresentation>();
for (Task task : tasks) {
dtos.add(new TaskRepresentation(task.getId(), task.getName()));
}
return dtos;
}
static class TaskRepresentation {
private String id;
private String name;
public TaskRepresentation(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
@Service 和 @RestController 都会被 Spring Boot 应用的自动组件扫描发现。
再次运行应用类。现在我们可以与 REST API 交互,例如使用 cURL:
curl http://localhost:8080/tasks?assignee=kermit
[]
curl -X POST http://localhost:8080/process
curl http://localhost:8080/tasks?assignee=kermit
[{"id":"10004","name":"my task"}]
可以看到,我们引用的是办理人 "kermit",它早先被硬编码进流程定义 XML。稍后我们会修改它,以便在启动工作流实例时设置办理人。
JPA 支持
要在 Spring Boot 中为 Flowable 添加 JPA 支持,添加以下依赖:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version</version>
</dependency>
这会在 Spring 配置中添加使用 JPA 所需的配置和 bean。默认情况下,JPA 提供方是 Hibernate。
让我们创建一个简单的 Entity 类:
@Entity
class Person {
@Id
@GeneratedValue
private Long id;
private String username;
private String firstName;
private String lastName;
private Date birthDate;
public Person() {
}
public Person(String username, String firstName, String lastName, Date birthDate) {
this.username = username;
this.firstName = firstName;
this.lastName = lastName;
this.birthDate = birthDate;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
}
默认情况下,当不使用内存数据库时,表不会自动创建。在 classpath 上创建一个 application.properties 文件并添加以下属性:
spring.jpa.hibernate.ddl-auto=update
添加以下类:
@Repository
public interface PersonRepository extends JpaRepository<Person, Long> {
Person findByUsername(String username);
}
这是一个 Spring repository,开箱即用地提供 CRUD。我们添加了按用户名查找 Person 的方法。Spring 会根据约定(通常是所使用的属性名)自动实现它。
现在我们进一 步增强服务:
- 向类添加 @Transactional。注意,由于添加了上面的 JPA 依赖,我们之前使用的 DataSourceTransactionManager 现在会自动被 JpaTransactionManager 替换。
- startProcess 现在传入一个办理人用户名,用于查找 Person,并把 Person JPA 对象作为流程变量放入流程实例。
- 添加一个创建示例用户的方法。它在 CommandLineRunner 中用于填充数据库。
@Service
@Transactional
public class MyService {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private PersonRepository personRepository;
public void startProcess(String assignee) {
Person person = personRepository.findByUsername(assignee);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("person", person);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
}
public List<Task> getTasks(String assignee) {
return taskService.createTaskQuery().taskAssignee(assignee).list();
}
public void createDemoUsers() {
if (personRepository.findAll().size() == 0) {
personRepository.save(new Person("jbarrez", "Joram", "Barrez", new Date()));
personRepository.save(new Person("trademakers", "Tijs", "Rademakers", new Date()));
}
}
}
CommandLineRunner 现在如下所示:
@Bean
public CommandLineRunner init(final MyService myService) {
return new CommandLineRunner() {
public void run(String... strings) throws Exception {
myService.createDemoUsers();
}
};
}
RestController 也做了少量修改以纳入上述变更(只展示新方法),HTTP POST 现在有一个包含办理人用户名的请求体:
@RestController
public class MyRestController {
@Autowired
private MyService myService;
@PostMapping(value="/process")
public void startProcessInstance(@RequestBody StartProcessRepresentation startProcessRepresentation) {
myService.startProcess(startProcessRepresentation.getAssignee());
}
...
static class StartProcessRepresentation {
private String assignee;
public String getAssignee() {
return assignee;
}
public void setAssignee(String assignee) {
this.assignee = assignee;
}
}
最后,要试用 Spring-JPA-Flowable 集成,我们在流程定义中使用 Person JPA 对象的 id 来分配任务:
<userTask id="theTask" name="my task" flowable:assignee="${person.id}"/>
这替换了我们最初设置的硬编码接收者 "kermit"。
现在我们可以启动一个新的流程实例,在 POST 请求体中提供用户名:
curl -H "Content-Type: application/json" -d '{"assignee" : "jbarrez"}' http://localhost:8080/process
任务列表现在使用 person id 获取:
curl http://localhost:8080/tasks?assignee=1
[{"id":"12505","name":"my task"}]
Flowable Actuator 端点
Flowable 提供一个 Spring Boot Actuator 端点,暴露正在运行的流程的信息。
默认情况下,flowable 端点映射到 /actuator/flowable。
Spring Boot 默认只向 Web 暴露少数端点(例如在 spring-boot-starter-actuator:2.5.4 中,Spring Boot 默认只向 Web 暴露 health 端点。关于默认向 Web 暴露的端点的更多信息,参见 https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.exposing)。要通过 Web 使用 flowable 端点,你需要在 application.properties 中添加 management.endpoints.web.exposure.include=flowable(注意:org.flowable.spring.boot.EndpointAutoConfiguration 类不像 HealthEndpointAutoConfiguration 类那样使用 @ConditionalOnAvailableEndpoint 注解来检查 flowable 端点是否既启用又暴露。因此要通过 Web 使用 flowable 端点,你唯一需要做的就是向配置文件添加 management.endpoints.web.exposure.include=flowable 或 management.endpoints.web.exposure.include=*)。
要启用 Actuator 端点,你需要添加 Actuator 依赖,例如使用 {sc-flowable-starter}/flowable-spring-boot-starter-actuator/pom.xml[flowable-spring-boot-starter-actuator]。
curl http://localhost:8080/actuator/flowable
{
"completedTaskCountToday": 0,
"deployedProcessDefinitions": [
"oneTaskProcess (v1)"
],
"processDefinitionCount": 1,
"cachedProcessDefinitionCount": 0,
"runningProcessInstanceCount": {
"oneTaskProcess (v1)": 0
},
"completedTaskCount": 2,
"completedActivities": 3,
"completedProcessInstanceCount": {
"oneTaskProcess (v1)": 0
},
"openTaskCount": 0
}
有关 Spring Boot Actuator 的更多信息,参见 Spring Boot 参考文档中的 Production Ready Endpoint。
Flowable Info Contributor
Flowable 还提供一个 Spring Boot InfoContributor,如下所示:
curl http://localhost:8080/actuator/info
{
"flowable": {
"version": "6.6.0"
}
}
Flowable 应用属性
Flowable 自动配置利用了 Spring Boot 的属性与配置机制。
参见 Spring Boot 参考指南中的 Properties and Configuration。
以下是 Flowable Spring Boot 支持所消费的配置属性列表。
# ===================================================================
# Common Flowable Spring Boot Properties
#
# This sample file is provided as a guideline. Do NOT copy it in its
# entirety to your own application. ^^^
# ===================================================================
# Core (Process) https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/FlowableProperties.java
flowable.check-process-definitions=true # Whether process definitions need to be auto deployed.
flowable.custom-mybatis-mappers= # The FQN of custom Mybatis mappers that need to be added to the engine.
flowable.custom-mybatis-x-m-l-mappers= # The location of the custom Mybatis XML Mappers that need to be added to the engine.
flowable.database-schema= # In some situations you want to set the schema to use for table checks / generation if the database metadata doesn't return that correctly.
flowable.database-schema-update=true # The strategy that should be used for the database schema.
flowable.db-history-used=true # Whether db history should be used.
flowable.deployment-name=SpringBootAutoDeployment # The name of the auto deployment.
flowable.history-level=audit # The history level that needs to be used.
flowable.process-definition-location-prefix=classpath*:/processes/ # The folder in which processes need to be searched for auto deployment.
flowable.process-definition-location-suffixes=**.bpmn20.xml,**.bpmn # The suffixes (extensions) of the files that needs to be deployed from the 'processDefinitionLocationPrefix' location.
# Process https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/process/FlowableProcessProperties.java
flowable.process.definition-cache-limit=-1 # The maximum amount of process definitions available in the process definition cache. Per default it is -1 (all process definitions).
flowable.process.enable-safe-xml=true # Enables extra checks on the BPMN xml that is parsed. Unfortunately, this feature is not available on some platforms, hence you need to disable if your platform does not allow the use of StaxSource during XML parsing.
flowable.process.servlet.load-on-startup=-1 # Load on startup of the Process dispatcher servlet.
flowable.process.servlet.name=Flowable BPMN Rest API # The name of the Process servlet.
flowable.process.servlet.path=/process-api # The context path for the Process rest servlet.
# Process Async Executor
flowable.process.async-executor-activate=true # Whether the async executor should be activated.
flowable.process.async.executor.async-job-lock-time=PT5M # The amount of time an async job is locked when acquired by the async executor. During this period of time, no other async executor will try to acquire and lock this job.
flowable.process.async.executor.default-async-job-acquire-wait-time=PT10S # The time the async job acquisition thread will wait to execute the next acquirement query. This happens when no new async jobs were found or when less async jobs have been fetched. Default value = 10 seconds.
flowable.process.async.executor.default-queue-size-full-wait-time=PT5S # The time the async job (both timer and async continuations) acquisition thread will wait when the queue is full to execute the next query.
flowable.process.async.executor.default-timer-job-acquire-wait-time=PT10S # The time the timer job acquisition thread will wait to execute the next acquirement query. This happens when no new timer jobs were found or when less async jobs have been fetched. Default value = 10 seconds.
flowable.process.async.executor.max-async-jobs-due-per-acquisition=1 # ???
flowable.process.async.executor.timer-lock-time=PT5M # The amount of time a timer job is locked when acquired by the async executor. During this period of time, no other async executor will try to acquire and lock this job.
# CMMN https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/cmmn/FlowableCmmnProperties.java
flowable.cmmn.deploy-resources=true # Whether to perform deployment of resources, default is 'true'.
flowable.cmmn.deployment-name=SpringBootAutoDeployment # The name of the deployment for the CMMN resources.
flowable.cmmn.enable-safe-xml=true # Enables extra checks on the DMN xml that is parsed. Unfortunately, this feature is not available on some platforms, hence you need to disable if your platform does not allow the use of StaxSource during XML parsing.
flowable.cmmn.enabled=true # Whether the CMMN engine needs to be started.
flowable.cmmn.resource-location=classpath*:/cases/ # The location where the CMMN resources are located.
flowable.cmmn.resource-suffixes=**.cmmn,**.cmmn11,**.cmmn.xml,**.cmmn11.xml # The suffixes for the resources that need to be scanned.
flowable.cmmn.servlet.load-on-startup=-1 # Load on startup of the CMMN dispatcher servlet.
flowable.cmmn.servlet.name=Flowable CMMN Rest API # The name of the CMMN servlet.
flowable.cmmn.servlet.path=/cmmn-api # The context path for the CMMN rest servlet.
# CMMN Async Executor
flowable.cmmn.async-executor-activate=true # Whether the async executor should be activated.
flowable.cmmn.async.executor.async-job-lock-time=PT5M # The amount of time an async job is locked when acquired by the async executor. During this period of time, no other async executor will try to acquire and lock this job.
flowable.cmmn.async.executor.default-async-job-acquire-wait-time=PT10S # The time the async job acquisition thread will wait to execute the next acquirement query. This happens when no new async jobs were found or when less async jobs have been fetched. Default value = 10 seconds.
flowable.cmmn.async.executor.default-queue-size-full-wait-time=PT5S # The time the async job (both timer and async continuations) acquisition thread will wait when the queue is full to execute the next query.
flowable.cmmn.async.executor.default-timer-job-acquire-wait-time=PT10S # The time the timer job acquisition thread will wait to execute the next acquirement query. This happens when no new timer jobs were found or when less async jobs have been fetched. Default value = 10 seconds.
flowable.cmmn.async.executor.max-async-jobs-due-per-acquisition=1 # ???
flowable.cmmn.async.executor.timer-lock-time=PT5M # The amount of time a timer job is locked when acquired by the async executor. During this period of time, no other async executor will try to acquire and lock this job.
# DMN https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/dmn/FlowableDmnProperties.java
flowable.dmn.deploy-resources=true # Whether to perform deployment of resources, default is 'true'.
flowable.dmn.deployment-name=SpringBootAutoDeployment # The name of the deployment for the dmn resources.
flowable.dmn.enable-safe-xml=true # Enables extra checks on the DMN xml that is parsed. Unfortunately, this feature is not available on some platforms, hence you need to disable if your platform does not allow the use of StaxSource during XML parsing.
flowable.dmn.enabled=true # Whether the dmn engine needs to be started.
flowable.dmn.history-enabled=true # Whether the history for the DMN engine should be enabled.
flowable.dmn.resource-location=classpath*:/dmn/ # The location where the dmn resources are located.
flowable.dmn.resource-suffixes=**.dmn,**.dmn.xml,**.dmn11,**.dmn11.xml # The suffixes for the resources that need to be scanned.
flowable.dmn.servlet.load-on-startup=-1 # Load on startup of the DMN dispatcher servlet.
flowable.dmn.servlet.name=Flowable DMN Rest API # The name of the DMN servlet.
flowable.dmn.servlet.path=/dmn-api # The context path for the DMN rest servlet.
flowable.dmn.strict-mode=true # Set this to false if you want to ignore the decision table hit policy validity checks to result in an failed decision table state. A result is that intermediate results created up to the point the validation error occurs are returned.
# IDM https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/idm/FlowableIdmProperties.java
flowable.idm.enabled=true # Whether the idm engine needs to be started.
flowable.idm.password-encoder= # The type of the password encoder that needs to be used.
flowable.idm.servlet.load-on-startup=-1 # Load on startup of the IDM dispatcher servlet.
flowable.idm.servlet.name=Flowable IDM Rest API # The name of the IDM servlet.
flowable.idm.servlet.path=/idm-api # The context path for the IDM rest servlet.
# IDM Ldap https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/ldap/FlowableLdapProperties.java
flowable.idm.ldap.attribute.email= # Name of the attribute that matches the user email.
flowable.idm.ldap.attribute.first-name= # Name of the attribute that matches the user first name.
flowable.idm.ldap.attribute.group-id= # Name of the attribute that matches the group id.
flowable.idm.ldap.attribute.group-name= # Name of the attribute that matches the group name.
flowable.idm.ldap.attribute.group-type= # Name of the attribute that matches the group type.
flowable.idm.ldap.attribute.last-name= # Name of the attribute that matches the user last name.
flowable.idm.ldap.attribute.user-id= # Name of the attribute that matches the user id.
flowable.idm.ldap.base-dn= # The base 'distinguished name' (DN) from which the searches for users and groups are started.
flowable.idm.ldap.cache.group-size=-1 # Allows to set the size of the {@link org.flowable.ldap.LDAPGroupCache}. This is an LRU cache that caches groups for users and thus avoids hitting the LDAP system each time the groups of a user needs to be known.
flowable.idm.ldap.custom-connection-parameters= # Allows to set all LDAP connection parameters which do not have a dedicated setter. See for example http://docs.oracle.com/javase/tutorial/jndi/ldap/jndi.html for custom properties. Such properties are for example to configure connection pooling, specific security settings, etc.
flowable.idm.ldap.enabled=false # Whether to enable LDAP IDM Service.
flowable.idm.ldap.group-base-dn= # The base 'distinguished name' (DN) from which the searches for groups are started.
flowable.idm.ldap.initial-context-factory=com.sun.jndi.ldap.LdapCtxFactory # The class name for the initial context factory.
flowable.idm.ldap.password= # The password that is used to connect to the LDAP system.
flowable.idm.ldap.port=-1 # The port on which the LDAP system is running.
flowable.idm.ldap.query.all-groups= # The query that is executed when searching for all groups.
flowable.idm.ldap.query.all-users= # The query that is executed when searching for all users.
flowable.idm.ldap.query.groups-for-user= # The query that is executed when searching for the groups of a specific user.
flowable.idm.ldap.query.user-by-full-name-like= # The query that is executed when searching for a user by full name.
flowable.idm.ldap.query.user-by-id= # The query that is executed when searching for a user by userId.
flowable.idm.ldap.query.group-by-id= # The query that is executed when searching for a specific group by groupId.
flowable.idm.ldap.search-time-limit=0 # The timeout (in milliseconds) that is used when doing a search in LDAP. By default set to '0', which means 'wait forever'.
flowable.idm.ldap.security-authentication=simple # The value that is used for the 'java.naming.security.authentication' property used to connect to the LDAP system.
flowable.idm.ldap.server= # The server host on which the LDAP system can be reached. For example 'ldap://localhost'.
flowable.idm.ldap.user= # The user id that is used to connect to the LDAP system.
flowable.idm.ldap.user-base-dn= # The base 'distinguished name' (DN) from which the searches for users are started.
# Flowable Mail https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/FlowableMailProperties.java
flowable.mail.server.default-from=flowable@localhost # The default from address that needs to be used when sending emails.
flowable.mail.server.force-to= # The force to address(es) that would be used when sending out emails. IMPORTANT: If this is set then all emails will be send to defined address(es) instead of the address configured in the MailActivity.
flowable.mail.server.host=localhost # The host of the mail server.
flowable.mail.server.password= # The password for the mail server authentication.
flowable.mail.server.port=1025 # The port of the mail server.
flowable.mail.server.ssl-port=1465 # The SSL port of the mail server.
flowable.mail.server.use-ssl=false # Sets whether SSL/TLS encryption should be enabled for the SMTP transport upon connection (SMTPS/POPS).
flowable.mail.server.use-tls=false # Set or disable the STARTTLS encryption.
flowable.mail.server.username= # The username that needs to be used for the mail server authentication. If empty no authentication would be used.
# Flowable Http https://github.com/flowable/flowable-engine/tree/main/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/FlowableHttpProperties.java
flowable.http.user-system-properties=false # Whether to use system properties (e.g. http.proxyPort).
flowable.http.connect-timeout=5s # Connect timeout for the http client
flowable.http.socket-timeout=5s # Socket timeout for the http client
flowable.http.connection-request-timeout=5s # Connection Request Timeout for the http client
flowable.http.request-retry-limit=3 # Request retry limit for the http client
flowable.http.disable-cert-verify=false # Whether to disable certificate validation for the http client
# Flowable REST
flowable.rest.app.cors.enabled=true # Whether to enable CORS requests at all. If false, the other properties have no effect
flowable.rest.app.cors.allow-credentials=true # Whether to include credentials in a CORS request
flowable.rest.app.cors.allowed-origins=* # Comma-separated URLs to accept CORS requests from
flowable.rest.app.cors.allowed-headers=* # Comma-separated HTTP headers to allow in a CORS request
flowable.rest.app.cors.allowed-methods=DELETE,GET,PATCH,POST,PUT # Comma-separated HTTP verbs to allow in a CORS request
flowable.rest.app.cors.exposed-headers=* # Comma-separated list of headers to expose in CORS response
# Actuator
management.endpoint.flowable.cache.time-to-live=0ms # Maximum time that a response can be cached.
management.endpoint.flowable.enabled=true # Whether to enable the flowable endpoint.
已废弃的属性
| 属性名 | 旧属性 | 默认值 | 描述 |
|---|---|---|---|
| flowable.process.servlet.name | flowable.rest-api-servlet-name | Flowable BPMN Rest API | Process servlet 的名称。 |
| flowable.process.servlet.path | flowable.rest-api-mapping | /process-api | Process rest servlet 的上下文路径。 |
| flowable.mail.server.host | flowable.mail-server-host | localhost | 邮件服务器的主机。 |
| flowable.mail.server.password | flowable.mail-server-password | - | 邮件服务器认证的密码。 |
| flowable.mail.server.port | flowable.mail-server-port | 1025 | 邮件服务器的端口。 |
| flowable.mail.server.ssl-port | flowable.mail-server-ssl-port | 1465 | 邮件服务器的 SSL 端口。 |
| flowable.mail.server.use-ssl | flowable.mail-server-use-ssl | false | 设置连接时是否为 SMTP 传输启用 SSL/TLS 加密(SMTPS/POPS)。 |
| flowable.mail.server.use-tls | flowable.mail-server-use-tls | false | 设置或禁用 STARTTLS 加密。 |
| flowable.mail.server.username | flowable.mail-server-user-name | - | 邮件服务器认证所需的用户名。为空则不使用认证。 |
| flowable.process.definition-cache-limit | flowable.process-definitions.cache.max | -1 | 流程定义缓存中可用的最大流程定义数量。默认为 -1(所有流程定义)。 |
Flowable 自动配置类
以下是 Flowable 提供的所有自动配置类列表,并附带文档与源码链接。
另外请查看你应用中的 conditions 报告,以了解哪些特性被开启的更多细节。
(为此,使用 --debug 或 -Ddebug 启动应用,或在 Actuator 应用中使用 conditions 端点)。
Flowable Starters
以下是 flowable spring boot starters 列表。
| Starter | 描述 |
|---|---|
| flowable-spring-boot-starter-cmmn | 包含以独立模式启动 CMMN Engine 的依赖 |
| flowable-spring-boot-starter-cmmn-rest | 包含以独立模式启动 CMMN Engine 并启动其 REST API 的依赖 |
| flowable-spring-boot-starter-dmn | 包含以独立模式启动 DMN Engine 的依赖 |
| flowable-spring-boot-starter-dmn-rest | 包含以独立模式启动 DMN Engine 并启动其 REST API 的依赖 |
| flowable-spring-boot-starter-process | 包含以独立模式启动 Process Engine 的依赖 |
| flowable-spring-boot-starter-process-rest | 包含以独立模式启动 Process Engine 并启动其 REST API 的依赖 |
| flowable-spring-boot-starter | 包含启动所有 Flowable 引擎(Process、CMMN、DMN 和 IDM)的依赖 |
| flowable-spring-boot-starter-rest | 包含启动所有 Flowable 引擎及其各自 REST API 的依赖 |
| flowable-spring-boot-starter-actuator | 包含 Spring Boot 所需的依赖 |
使用 Liquibase
Flowable 各引擎使用 Liquibase 管理其表的版本。
这意味着 Spring Boot 的 LiquibaseAutoConfiguration 会自动生效。
然而,如果你不使用 Liquibase,应用将无法启动并抛出异常。
为此,Flowable 把 spring.liquibase.enabled 设为 false,这意味着如果你需要使用 Liquibase,必须显式启用它。
延伸阅读
显然,Spring Boot 还有很多内容尚未涉及,比如非常简单的 JTA 集成,或构建一个可以在主流应用服务器上运行的 WAR 文件。
Spring Boot 集成还有更多内容:
- Actuator 支持
- Spring Integration 支持
- Rest API 集成:在 Spring 应用中启动嵌入式的 Flowable Rest API
- Spring Security 支持