使用eclipse和maven创建activiti项目基础配置

项目组最近的项目使用到了activiti工作流,到处查找了一些资料后,初步完成任务。但是我所做的事只是在搭好的环境中调用接口和方法操作,因此自己尝试着也从搭建环境入手,以下是成功实现以后的记录。

实现目标:成功创建activiti相关的24张表并进行简单操作。

使用环境:eclipse4.4.1、tomcat7、jdk1.7、mysql5.6.25、maven3.2.5、activiti5.16。

maven导入基础依赖包的配置

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>activitiTest</groupId>
  <artifactId>activitiTest</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>activitiTest Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.activiti</groupId>
      <artifactId>activiti-engine</artifactId>
      <version>5.16</version>
      <scope>test</scope>
    </dependency>

    <dependency>
    	<groupId>org.activiti</groupId>
    	<artifactId>activiti-bpmn-converter</artifactId>
    	<version>5.16</version>
    </dependency>
    <dependency>
    	<groupId>org.activiti</groupId>
    	<artifactId>activiti-bpmn-model</artifactId>
    	<version>5.16</version>
    </dependency>
    <dependency>
    	<groupId>org.activiti</groupId>
    	<artifactId>activiti-bpmn-layout</artifactId>
    	<version>5.16</version>
    </dependency>
    <dependency>
    	<groupId>mysql</groupId>
    	<artifactId>mysql-connector-java</artifactId>
    	<version>5.1.34</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>activitiTest</finalName>
  </build>
</project>

activiti主配置文件activiti.cfg.xml连接数据库创建引擎的配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
		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">

	<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
	    <property name="databaseType" value="mysql"></property>
		<property name="jdbcDriver" value="com.mysql.jdbc.Driver" ></property>
		<property name="jdbcUrl" value="jdbc:mysql://192.168.0.33:3306/activititest?useUnicode=true&characterEncoding=utf8" ></property>
		<property name="jdbcUsername" value="root" ></property>
		<property name="jdbcPassword" value="123456" ></property>
		<property name="databaseSchemaUpdate" value="true" />
	    <property name="jobExecutorActivate" value="false"/>
	    <property name="history" value="full"/>
	</bean>
</beans>

java测试代码

package activitiTest;

import java.io.InputStream;
import java.util.zip.ZipInputStream;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;

public class ActTest {
	public void actDeployement() {
		ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
		InputStream inputStream = this.getClass().getClassLoader()
				.getResourceAsStream("actTest1.zip");
		ZipInputStream zipInputStream = new ZipInputStream(inputStream);
		processEngine.getRepositoryService().createDeployment()
				.name("activiti测试").addZipInputStream(zipInputStream).deploy();
	}
}


项目结构如下图:
使用eclipse和maven创建activiti项目基础配置

启动测试代码后数据库表如下图

使用eclipse和maven创建activiti项目基础配置

参考文档:activiti5.16用户手册

上一篇:DataGrid3


下一篇:1965: [Ahoi2005]SHUFFLE 洗牌 - BZOJ