使用flowable整合springboot 应该怎么写
时间: 2023-07-08 21:20:09 浏览: 102
要使用Flowable整合Spring Boot,您需要遵循以下步骤:
1. 首先,添加Flowable依赖项。在pom.xml文件中添加以下依赖项:
```xml
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.6.0</version>
</dependency>
```
2. 创建一个ProcessEngineConfigurationConfigurer bean来配置Flowable引擎。在Spring Boot应用程序中,您可以使用application.yml或application.properties文件来配置引擎。
```java
@Configuration
public class FlowableConfig {
@Bean
public ProcessEngineConfigurationConfigurer myProcessEngineConfigurationConfigurer() {
return processEngineConfiguration -> {
processEngineConfiguration.setAsyncExecutorActivate(false);
processEngineConfiguration.setHistoryLevel(HistoryLevel.AUDIT);
};
}
}
```
3. 创建一个ProcessEngine和一个TaskService bean。
```java
@Configuration
public class FlowableConfig {
@Bean
public ProcessEngineConfigurationConfigurer myProcessEngineConfigurationConfigurer() {
return processEngineConfiguration -> {
processEngineConfiguration.setAsyncExecutorActivate(false);
processEngineConfiguration.setHistoryLevel(HistoryLevel.AUDIT);
};
}
@Bean
public ProcessEngine processEngine(SpringProcessEngineConfiguration configuration) {
return configuration.buildProcessEngine();
}
@Bean
public TaskService taskService(ProcessEngine processEngine) {
return processEngine.getTaskService();
}
}
```
4. 最后,您可以在您的Spring Boot应用程序中使用Flowable服务。
```java
@Service
public class MyService {
private final RuntimeService runtimeService;
public MyService(RuntimeService runtimeService) {
this.runtimeService = runtimeService;
}
public void startProcessInstance(String processDefinitionKey) {
runtimeService.startProcessInstanceByKey(processDefinitionKey);
}
}
```
这就是整合Flowable和Spring Boot的基本步骤。您可以根据您的需求进行更高级的配置。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)