springboot1.5.10+activiti6.0集成

基于springboot1.5.10.RELEASE

 <!--activiti的jar -->
<dependency>
      <groupId>org.activiti</groupId>
      <artifactId>activiti-spring</artifactId>
      <version>6.0.0</version>
  </dependency>    

开发流程设计软件安装

eclipse的安装教程如下:install new software 然后安装新软件如下图:
在这里插入图片描述
名称:Activiti6.0
位置:http://activiti.org/designer/update/
安装完成以后,在下在你的新建会看到这个
在这里插入图片描述

代码实例

jar包导入完成以后,写一个配置

import java.io.IOException;
import javax.sql.DataSource;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.transaction.PlatformTransactionManager;

@Configuration
public class ActivitiConfiguration {

    @Autowired
    private DataSource dataSource;
    @Autowired
    private PlatformTransactionManager platformTransactionManager;
 
	@Bean
	public SpringProcessEngineConfiguration springProcessEngineConfiguration(){
		System.out.println("==========配置加载完成===============================");
		SpringProcessEngineConfiguration spec = new SpringProcessEngineConfiguration();
        spec.setDataSource(dataSource);
        spec.setTransactionManager(platformTransactionManager);
		spec.setDatabaseSchemaUpdate("true");
		Resource[] resources = null;
        // 启动自动部署流程
		try {
			resources =  new PathMatchingResourcePatternResolver().getResources("classpath:bpmn/*.bpmn");
		} catch (IOException e) {
			e.printStackTrace();
		}
		spec.setDeploymentResources(resources);
		return spec;
	}
	
	@Bean
	public ProcessEngineFactoryBean processEngine(){
		ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
		processEngineFactoryBean.setProcessEngineConfiguration(springProcessEngineConfiguration());
		return processEngineFactoryBean;
	}
 
	
	@Bean
	public RepositoryService repositoryService() throws Exception{
		return processEngine().getObject().getRepositoryService();
	}
	@Bean
	public RuntimeService runtimeService() throws Exception{
		return processEngine().getObject().getRuntimeService();
	}
	@Bean
	public TaskService taskService() throws Exception{
		return processEngine().getObject().getTaskService();
	}
	@Bean
	public HistoryService historyService() throws Exception{
		return processEngine().getObject().getHistoryService();
	}

}
项目启动中看到《配置加载完成=====================》表示配置加载完成
在你的数据库中有如下表,表示基本完成
在这里插入图片描述
** bpmn的文件自己定义路径**
注意要和resources = new PathMatchingResourcePatternResolver().getResources(“classpath:bpmn/*.bpmn”);这个对应
我放在如下图下:
在这里插入图片描述

后台代码完成剩余的本人还没有研究;如有问题欢迎留言交流

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值