您的位置:首页 > 编程语言 > Java开发

eclipse创建activiti项目,mysql作数据库

2017-08-30 09:02 489 查看
准备:eclipse已成功安装activiti插件,MySQL

1.新建activiti项目



2.新建activiti diagram与设置配置文件

项目结构如下:



pom.xml,这里我用的是mysql

<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>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>activitiTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<activiti-version>5.17.0</activiti-version>

</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti-version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-converter</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-model</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-layout</artifactId>
<version>${activiti-version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.36</version>
</dependency>
</dependencies>
<build>
<finalName>activitiTest</finalName>
</build>
</project>


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://localhost:3306/activititest?useUnicode=true&characterEncoding=utf-8"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="******"></property>
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="history" value="full" />
</bean>
</beans>
注意:在xml配置文件中配置数据库URL时,要使用&的转义字符也就是&;

有时xml报错,可能是依赖包版本变更,换一个版本;可能排版问题,使用快捷键ctrl+shift+F,自动排版

3.右键项目->create deployment artifact,右键bpmn->activiti->generate unit test,右键项目->Run As->JUnit Test

在数据库内能看到流程数据:



这里用的是SQLyog工具。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  eclipse activiti mysql