activiti实战--第二章--搭建Activiti开发环境及简单示例

(一)搭建开发环境

学习资料:《Activiti实战》

 

第一章 认识Activiti

2.1 下载Activiti

官网:http://activiti.org/download.html

入下载页后,可以看到最新版本的压缩包、快速入门、用户手册、javadoc等。我下载的时候,最新版本是activiti-5.22.0.zip

 

目录结构:

 

database:

包含了activiti表的创建、删除及版本升级三种类型的脚本。

创建和删除脚本的命名规则:activiti.[oracle|postgres|db2|mssql|mysql|h2|hsql].[create|drop].[identity|engine|history].sql

版本升级脚本的命名规则:activiti.oracle.upgradestep.[5x].to.[5(x+1)].history

 

docs:

包含了javadocs、用户手册和xsd。用户手册包含了环境配置,十分钟快速入门,各模块使用教程。xsd中包含与流程定义相关的scheme。

 

libs:略。

war:略。

 

2.2 环境配置

jdk、maven、intellij。

 

2.3 配置文件介绍

2.3.1 activiti.cfg.xml

(1)processEngineConfiguration

activiti可以单独使用,也可以与spring集成,所以配置文件有所区别。

单独模式:

activiti实战--第二章--搭建Activiti开发环境及简单示例_第1张图片

与spring集成:

 

 (2)database

activiti支持的数据库类型:

 

不论是单独模式,还是与spring集成,database都可以有如下配置方式。

jdbc方式(spring集成时也类似,不再重复)

activiti实战--第二章--搭建Activiti开发环境及简单示例_第2张图片

 

 

dataSource方式(spring集成时也类似,不再重复):

2.3.2 pom.xml

如果不与spring集成,只需要activiti-engine。

如果需要与spring集成,需要加上activiti-spring。其中spring的配置此处略。

如果需要使用activiti的modeler,需要加上activiti-modeler。


    <dependency>  
      <groupId>org.activitigroupId>  
      <artifactId>activiti-engineartifactId>  
      <version>${activiti.version}version>  
    dependency>
    
    
    <dependency>
          <groupId>org.activitigroupId>
          <artifactId>activiti-springartifactId>
          <version>${activiti.version}version>  
      dependency>
    
    
    <dependency>
        <groupId>org.activitigroupId>
        <artifactId>activiti-modelerartifactId>
            <version>${activiti.version}version>
    dependency>

2.4 完整的配置文件示例

(1)单独模式 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.StandaloneProcessEngineConfiguration">
        <property name="jdbcUrl" value="jdbc:h2:file:~/activiti-in-action-chapter7;AUTO_SERVER=TRUE" />
        <property name="jdbcDriver" value="org.h2.Driver" />
        <property name="jdbcUsername" value="sa" />
        <property name="jdbcPassword" value="" />

        <property name="databaseSchemaUpdate" value="true" />
        <property name="jobExecutorActivate" value="false" />
    bean>
beans>

补充下mysql的

    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti" />
        <property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUsername" value="root" />
        <property name="jdbcPassword" value="123456" />

 

(2)与spring集成 applicationContext.xml

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

    
    <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
        <property name="driverClass" value="org.h2.Driver" />
        <property name="url" value="jdbc:h2:file:~/activiti-in-action-chapter7;AUTO_SERVER=TRUE" />
        <property name="username" value="sa" />
        <property name="password" value="" />
    bean>

    
    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <property name="processEngineName" value="spring">property>
        <property name="dataSource" ref="dataSource" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="databaseSchemaUpdate" value="true" />
        <property name="jobExecutorActivate" value="false" />
        <property name="deploymentResources" value="classpath*:/chapter7/leave.zip">property>
    bean>

    
    <bean id="processEngineFactory" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    bean>

    
    <bean id="repositoryService" factory-bean="processEngineFactory" factory-method="getRepositoryService" />
    <bean id="runtimeService" factory-bean="processEngineFactory" factory-method="getRuntimeService" />
    <bean id="formService" factory-bean="processEngineFactory" factory-method="getFormService" />
    <bean id="identityService" factory-bean="processEngineFactory" factory-method="getIdentityService" />
    <bean id="taskService" factory-bean="processEngineFactory" factory-method="getTaskService" />
    <bean id="historyService" factory-bean="processEngineFactory" factory-method="getHistoryService" />
    <bean id="managementService" factory-bean="processEngineFactory" factory-method="getManagementService" />

beans>

 

转载于:https://www.cnblogs.com/shanheyongmu/p/8416757.html

你可能感兴趣的:(java,数据库)