Routine集成flowable
时间: 2023-06-17 11:02:39 浏览: 171
将Routine集成Flowable,可以通过以下步骤完成:
1. 在pom.xml中添加Flowable的依赖:
```xml
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.6.0</version>
</dependency>
```
2. 在Spring Boot配置文件中,添加Flowable的配置:
```yaml
spring:
activiti:
database-schema-update: true
history-level: full
```
3. 创建一个Flowable的配置类,用于配置Flowable引擎:
```java
@Configuration
public class FlowableConfig {
@Bean
public ProcessEngineConfigurationImpl processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
configuration.setDataSource(dataSource);
configuration.setTransactionManager(transactionManager);
configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
configuration.setHistory(ProcessEngineConfiguration.HISTORY_FULL);
return configuration;
}
@Bean
public ProcessEngineFactoryBean processEngine(ProcessEngineConfigurationImpl configuration) {
ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
factoryBean.setProcessEngineConfiguration(configuration);
return factoryBean;
}
@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();
}
}
```
4. 在需要使用Flowable的类中,注入相应的服务:
```java
@Service
public class FlowableService {
@Autowired
private RepositoryService repositoryService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
//...
}
```
这样,就可以在Spring Boot应用中使用Flowable了。
阅读全文