springboot集成flowable
时间: 2023-08-29 08:13:24 浏览: 85
springboot 集成flowable 6.80
Spring Boot 集成 Flowable 的过程很简单,可以通过以下步骤来实现:
1. 在 pom.xml 文件中添加 Flowable 依赖。
```
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-process</artifactId>
<version>6.5.0</version>
</dependency>
```
2. 在 application.properties 文件中配置 Flowable 数据源。
```
spring.datasource.url=jdbc:h2:mem:flowable
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
```
3. 创建 Flowable 的配置类。
```
@Configuration
@AutoConfigureAfter({ DataSourceAutoConfiguration.class, FlywayAutoConfiguration.class })
public class FlowableConfig {
@Autowired
private DataSource dataSource;
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
PlatformTransactionManager transactionManager,
SpringAsyncExecutor springAsyncExecutor) {
SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
configuration.setDataSource(dataSource);
configuration.setDatabaseSchemaUpdate("true");
configuration.setAsyncExecutorEnabled(true);
configuration.setAsyncExecutor(springAsyncExecutor);
configuration.setTransactionManager(transactionManager);
return configuration;
}
@Bean
public ProcessEngine processEngine(
SpringProcessEngineConfiguration springProcessEngineConfiguration) {
return springProcessEngineConfiguration.buildProcessEngine();
}
@Bean
public RepositoryService repositoryService(ProcessEngine processEngine) {
return processEngine.getRepositoryService();
}
@Bean
public RuntimeService runtimeService(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}
@Bean
public TaskService taskService(ProcessEngine processEngine) {
return processEngine.getTaskService();
}
@Bean
public HistoryService historyService(ProcessEngine processEngine) {
return processEngine.getHistoryService();
}
@Bean
public ManagementService managementService(ProcessEngine processEngine) {
return processEngine.getManagementService();
}
@Bean
public FormService formService(ProcessEngine processEngine) {
return processEngine.getFormService();
}
@Bean
public IdentityService identityService(ProcessEngine processEngine) {
return processEngine.getIdentityService();
}
}
```
4. 在启动类上添加 @EnableProcessEngine 和 @Import(FlowableConfig.class) 注解。
```
@
阅读全文