activiti使用详解(一)

简单的api程序示例(maven工程):


下载链接: http://pan.baidu.com/s/1pJ1TfgZ

https://github.com/frederikheremans/activiti-dynamic-process

http://topmanopensource.iteye.com/blog/1315258


pom.xml
    xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0  http://maven.apache.org/maven-v4_0_0.xsd">
  4.0.0
  org.activiti.examples
  activiti-examples
  1.0-SNAPSHOT
  jar
  BPMN 2.0 with Activiti - Examples
  
    5.18.0
  

  
    
      org.activiti
      activiti-engine
      ${activiti-version}
    

    
      org.activiti
      activiti-spring
      ${activiti-version}
    

    
      org.codehaus.groovy
      groovy-all
      2.4.3
    

    
      com.h2database
      h2
      1.3.168
    

    
      org.slf4j
      slf4j-api
      1.7.6
    

    
      org.slf4j
      slf4j-jdk14
      1.7.6
    

    
      junit
      junit
      4.11
    

    

mysql
mysql-connector-java
5.1.29

  

 
    
      
        org.apache.maven.plugins
        maven-compiler-plugin
       2.3.2
        
         1.6
         1.6
       

     

     
        org.apache.maven.plugins
        maven-eclipse-plugin
        true
        
         
           org.eclipse.jdt.USER_LIBRARY/Activiti Designer Extensions
         

       

     

    

 



第一种方式使用代码形式创建数据库(不推荐,建议使用方法二的:配置文件):
activiti使用详解(一)_第1张图片

package junit;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
public class TestActivit{
 
 @Test
 public void creatTable(){
  ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
  processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
  processEngineConfiguration.setJdbcUrl("jdbc:mysql://172.31.2.14:3306/activiti?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true");
  processEngineConfiguration.setDatabaseSchemaUpdate(processEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP);
  processEngineConfiguration.setJdbcUsername("root");
  processEngineConfiguration.setJdbcPassword("yunjisuan");
 
  ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
 }
}





方法二(使用spring 配置文件依赖注入-建议使用此方法):
activiti使用详解(一)_第2张图片
package junit;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
public class TestActivit{
 
 @Test
 public void creatTable(){
  ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
  processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
  processEngineConfiguration.setJdbcUrl("jdbc:mysql://172.31.2.14:3306/activiti?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true");
  processEngineConfiguration.setDatabaseSchemaUpdate(processEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP);
  processEngineConfiguration.setJdbcUsername("root");
  processEngineConfiguration.setJdbcPassword("yunjisuan");
 
  processEngineConfiguration.buildProcessEngine();
 }
 
 @Test
 public void creatTable2(){
  ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
 }
}

需要增加一个配置文件:
activiti使用详解(一)_第3张图片


  xmlns:context=" http://www.springframework.org/schema/context" xmlns:tx=" http://www.springframework.org/schema/tx"
  xmlns:jee=" http://www.springframework.org/schema/jee" xmlns:aop=" http://www.springframework.org/schema/aop"
  xsi:schemaLocation=" http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/jee  http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
        http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
       
class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">






  


activiti使用详解(一)_第4张图片



activiti使用详解(一)_第5张图片


activiti使用详解(一)_第6张图片

你可能感兴趣的:(activiti)