activity学习

最近在学习activity工作流,  将学习的点滴记录起来。

1、构建maven项目,导入activity包,在mysql数据库生成25张表。

是pom.xml配置,

<dependencies>  
    <dependency>  
      <groupId>junit</groupId>  
      <artifactId>junit</artifactId>  
      <version>3.8.1</version>  
      <scope>test</scope>  
    </dependency>  
   <dependency>
		<groupId>org.activiti</groupId>
		<artifactId>activiti-engine</artifactId>
		<version>5.19.0.2</version>
	</dependency>
	
	<dependency>
		<groupId>org.activiti</groupId>
		<artifactId>activiti-spring</artifactId>
		<version>5.19.0.2</version>
	</dependency>
	
	<dependency>
		<groupId>org.activiti</groupId>
		<artifactId>activiti-bpmn-model</artifactId>
		<version>5.19.0.2</version>
	</dependency>
	
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.38</version>
	</dependency>
  </dependencies>  

2、生成数据库的表。

package com.activity;

import org.activiti.engine.ProcessEngineConfiguration;

/**
 * Hello world!
 *
 */
public class App 
{
	
    public static void main( String[] args )
    {
    	//工作流配置对象
    	ProcessEngineConfiguration pe = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
    	pe.setJdbcDriver("com.mysql.jdbc.Driver");     //mysql 的驱动
    	pe.setJdbcUrl("jdbc:mysql://localhost:3306/activity?useUnicode=true&characterEncoding=utf8");  //url地址
    	pe.setJdbcUsername("root");
    	pe.setJdbcPassword("123456");
	//参数可以直接写true
    	pe.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    	
    	//构建引擎流程的对象,创建表
    	pe.buildProcessEngine();
        System.out.println( "Hello World!" );
    }
}

2.(2)这是配置文件获取引擎的方式  

<?xml version="1.0" encoding="UTF-8"?>
<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:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
	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.xsd">
     					   
     					   
	<!-- activiti流程引擎 -->


<!-- 	流程引擎配置 -->
  	<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
		<property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activity" />
		<property name="jdbcUsername" value="root" />
		<property name="jdbcPassword" value="123456" />
		<property name="databaseSchemaUpdate" value="true" />
	</bean>
</beans>
执行代码:
package com.activity;

import org.activiti.engine.ProcessEngineConfiguration;

/**
 * Hello world!
 *
 */
public class App 
{
	
    public static void main( String[] args )
    {
/*    	//工作流配置对象
    	ProcessEngineConfiguration pe = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
    	pe.setJdbcDriver("com.mysql.jdbc.Driver");     //mysql 的驱动
    	pe.setJdbcUrl("jdbc:mysql://localhost:3306/activity?useUnicode=true&characterEncoding=utf8");
    	pe.setJdbcUsername("root");
    	pe.setJdbcPassword("123456");
    	pe.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    	
    	//获取流程引擎对象
    	pe.buildProcessEngine();
        System.out.println( "Hello World!" );*/
        
    	//试试配置文件
        ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activity/spring-activiti.xml");
        configuration.buildProcessEngine();
    }
}


配置数据可以配置在配置文件里,

3、执行代码生成数据表



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值