Activiti学习笔记1 — 下载与开发环境的配置

一、下载

JDK下载URL:

Tomcat下载URL:http://tomcat.apache.org/ 

Eclipse下载URL:http://www.oracle.com/technetwork/java/javase/downloads/index.html 

MySql 下载URL:http://dev.mysql.com/downloads/

Activiti下载URL:http://www.activiti.org/download.html

Activiti Eclipse 插件下载URL:http://www.activiti.org/designer/archived/

二、安装

1、本地安装Activiti Eclipse 插件

处理错误

在安装Activiti Eclipse 插件时,可能会出错,错误提示如下:

An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.emf.transaction,1.9.0.201506010221
No repository found containing: osgi.bundle,org.eclipse.emf.validation,1.8.0.201505312255
No repository found containing: osgi.bundle,org.eclipse.emf.workspace,1.5.1.201506010221

提示Eclipse中缺少以上三个插件,这三个插件需要下载Eclipse的“Eclipse IDE for Automotive Software Developers”版本,从这个版本中把以上三个插件复制到Eclipse中,再重新安装即可。

2、在线安装

Name:Activiti BPMN2.0 designer
Location: http://activiti.org/designer/update/

三、通过代码安装数据库,测试环境

1、纯代码方式

 1 /**
 2      * 在代码中创建配置,测试Activiti数据库环境是否建立
 3      */
 4     @Test
 5     public void testActivitiEnvironment1() {
 6         // 1、创建流程引擎配置对象
 7         ProcessEngineConfiguration configuration = ProcessEngineConfiguration
 8                 .createStandaloneProcessEngineConfiguration();
 9         // 2、配置数据库连接配置
10         // 2.1、数据库连接URL
11         configuration.setJdbcUrl("jdbc:mysql://localhost:3306/activiti_test?createDatabaseIfNotExist=true");
12         // 2.2、数据库连接驱动
13         configuration.setJdbcDriver("com.mysql.jdbc.Driver");
14         // 2.3、数据库连接用户名
15         configuration.setJdbcUsername("root");
16         // 2.4、数据库连接密码
17         configuration.setJdbcPassword("root");
18         // 2.5、 配置数据库建表策略
19         configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
20 
21         // 3、通过配置对象创建ProcessEngine;
22         ProcessEngine processEngine = configuration.buildProcessEngine();
23 
24     }
View Code

2、配置文件方式

  2.1、配置文件 activiti.cfg.xml  

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 3         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
 4         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
 5 
 6     <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
 7         <!-- 数据库连接属性 -->
 8         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?characterEncoding=utf-8"></property>
 9         <property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
10         <property name="jdbcUsername" value="root"></property>
11         <property name="jdbcPassword" value="root"></property>
12         
13         <!-- 数据库更新策略 -->
14         <property name="databaseSchemaUpdate" value="true"></property>
15         
16         <property name="jobExecutorActivate" value="false"></property>
17         
18         <!-- 邮件服务地址 -->
19         <property name="mailServerHost" value="mail.wxintl.com"></property>
20         <property name="mailServerPort" value="5025"></property>
21     </bean>
22 
23 </beans>
View Code

  2.2、代码

 1 /**
 2      * 从配置文件中读取配置,测试Activiti数据库环境是否建立
 3      */
 4     @Test
 5     public void testActivitiEnvironment2() {
 6         
 7         ProcessEngineConfiguration configuration = ProcessEngineConfiguration
 8                 .createProcessEngineConfigurationFromResource("/activiti.cfg.xml");
 9         
10         ProcessEngine processEngine = configuration.buildProcessEngine();
11         
12         
13     }
View Code

 四、学习资料

http://pan.baidu.com/s/1sjt0IXv

http://pan.baidu.com/s/1gdvLQ5X

原文地址:https://www.cnblogs.com/maocs/p/5009846.html