亲宝软件园·资讯

展开

activiti环境搭建 Activiti开发环境的搭建过程详解

人气:0

本文中使用maven+eclipse搭建activiti-5.14的开发环境

一、创建maven工程

创建一个普通的java工程,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.lyy</groupId>
  <artifactId>activtiviti-study-01</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.activiti</groupId>
      <artifactId>activiti-engine</artifactId>
      <version>5.14</version>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.26</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>

    <dependency>
      <groupId>c3p0</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.1.2</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

二、添加activiti的配置文件

在工程的resources目录下创建activiti的配置文件,名称为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名称的流程引擎配置对象 -->
  <bean id="processEngineConfiguration"
    class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti_01"></property>
    <property name="jdbcUsername" value="root"></property>
    <property name="jdbcPassword" value="root"></property>
    <property name="databaseSchemaUpdate" value="true"></property>
  </bean>

</beans>

三、测试

新建一个测试类,添加如下代码,

public class Test1 {
  /**
   * 测试环境是否可用
   */
  @Test
  public void test1() {
  ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
  System.out.println(configuration);
  }

}

运行测试方法test1,如果正常执行,并输出ProcessEngineConfiguration对象的地址,则表示开发环境搭建成功。

四、总结

用maven搭建activiti的开发环境,需要先引入activiti的依赖

<dependency>
  <groupId>org.activiti</groupId>
  <artifactId>activiti-engine</artifactId>
  <version>5.14</version>
</dependency>

因为要操作数据库,所以需要引入msql的驱动和数据库连接池

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.26</version>
</dependency>
<dependency>
  <groupId>c3p0</groupId>
  <artifactId>c3p0</artifactId>
  <version>0.9.1.2</version>
  <type>jar</type>
  <scope>compile</scope>
</dependency>

加载全部内容

相关教程
猜你喜欢
用户评论