1.pom.xml
<dependency> <br />
<groupId>org.activiti</groupId><br />
<artifactId>activiti-spring-boot-starter-basic</artifactId><br />
<version>5.22.0</version><br />
</dependency><br />
2. resources目录下新建processes文件夹放一个xxx.bpmn流程文件
<p>可以自定义默认流程引擎的包,在yml里面设置 例如:</p>
activiti:
database-schema-update: false
job-executor-activate: true
async-executor-activate: true
process-definition-location-prefix: classpass:/myProcess
3. 定时流程设置
<p>定时流程分定时ServiceTask,和超时UserTask。前者直接在流程节点前面添加一个定时器指定定时时间即可。后者在节点内添加定时器指定到期时间,再从定时器中引线到超时任务处理的task即可,如图:
4. 指定uuid生成策略
@Configuration
public class ActivitiConfig extends AbstractProcessEngineAutoConfiguration {
//注入数据源和事务管理器
@Bean
@ConditionalOnMissingBean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
DataSource dataSource, EntityManagerFactory entityManagerFactory,
PlatformTransactionManager transactionManager, SpringAsyncExecutor springAsyncExecutor) throws IOException {
SpringProcessEngineConfiguration config = this.baseSpringProcessEngineConfiguration(dataSource,
transactionManager, springAsyncExecutor);
config.setJpaEntityManagerFactory(entityManagerFactory);
config.setTransactionManager(transactionManager);
config.setIdGenerator(new StrongUuidGenerator());
config.setJpaHandleTransaction(false);
config.setJpaCloseEntityManager(false);
return config;
}
}