首页 > 代码库 > activiti 插件安装,以及初始化配置

activiti 插件安装,以及初始化配置

1.安装插件

2.添加pom

3.配置activiti.cfg.xml

4.绘制业务流程图 MyProcess.bpmn

5.加载activiti数据表

6.创建流程

 

1.安装eclipse activiti 插件

Activiti BPMN 2.0 designer
http://activiti.org/designer/update/

 

help-->install new softWare

技术分享

 

2.添加pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.qi</groupId>
	<artifactId>activitiDemo</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<dependencies>
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-engine</artifactId>
			<version>5.21.0</version>
		</dependency>
		<dependency>
			<groupId>org.activiti</groupId>
			<artifactId>activiti-spring</artifactId>
			<version>5.21.0</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.7.10</version>
		</dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>1.1.2</version>
		</dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-core</artifactId>
			<version>1.1.2</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.38</version>
		</dependency>

	</dependencies>

</project>

  

3.配置activiti.cfg.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">


	<bean id="processEngineConfiguration"
		class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
		<property name="jdbcDriver" value="http://www.mamicode.com/com.mysql.jdbc.Driver" />
		<property name="jdbcUrl"
			value="http://www.mamicode.com/jdbc:mysql://localhost:3306/test?characterEncoding=utf8" />
		<property name="jdbcUsername" value="http://www.mamicode.com/root" />
		<property name="jdbcPassword" value="http://www.mamicode.com/centos" />
		<property name="databaseSchemaUpdate" value="http://www.mamicode.com/true" />
	</bean>
</beans>

4.绘制业务流程图 MyProcess.bpmn

技术分享

 

5.加载activiti数据表

6.创建流程

package activitiDemo;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

public class JunitTest {

	/**
	 * 加载activiti 表
	 */
	@Test
	public void installActiviti() {
		//表不存在的话创建表
		ProcessEngine processEngine = ProcessEngineConfiguration
				.createProcessEngineConfigurationFromResource("activiti.cfg.xml")
		.buildProcessEngine();

		System.out.println("------processEngine:" + processEngine);

	}
	
	/**
	 * 创建activiti流程
	 */
	@Test
	public void createProcess() {
		//创建流程
		ProcessEngine processEngine = ProcessEngineConfiguration
				.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
		Deployment deployment = processEngine.getRepositoryService().createDeployment().name("请假程序")
		.addClasspathResource("diagrams/MyProcess.bpmn").addClasspathResource("diagrams/MyProcess.png").deploy();

		System.out.println(deployment.getId());
		System.out.println(deployment.getName());
	}
}

  

 

activiti 插件安装,以及初始化配置