Activiti学习入门(1) -- 创建Activiti的23张表

学习分别通过代码和Spring注入的方式创建Activiti数据表(共23张表)


一、Java代码:

package com.steven.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;

/**
 * Activiti学习入门
 * 
 * @author Steven 2015年 下午11:36:39
 */
public class TestActiviti {

	/**
	 * 通过代码的方式创建Activiti数据表(共23张表)
	 */
	@Test
	public void createTableByCode() {
		ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
				.createStandaloneProcessEngineConfiguration();
		// 连接数据库的配置
		processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
		processEngineConfiguration
				.setJdbcUrl("jdbc:mysql://localhost:3306/StevenActiviti?useUnicode=true&characterEncoding=utf8");
		processEngineConfiguration.setJdbcUsername("root");
		processEngineConfiguration.setJdbcPassword("");
		// Activiti的23个表不存在则自动创建
		processEngineConfiguration
				.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
		// 工作流的核心对象,ProcessEnginee对象
		ProcessEngine processEngine = processEngineConfiguration
				.buildProcessEngine();
		System.out.println("创建ProcessEnginee对象成功:" + processEngine);
	}

	/**
	 * 通过Spring注入的方式创建Activiti数据表(共23张表)
	 */
	@Test
	public void createTablesBySpring() {
		ProcessEngine processEngine = ProcessEngineConfiguration
				.createProcessEngineConfigurationFromResource(
						"activiti.cfg.xml") //
				.buildProcessEngine();
		System.out.println("创建ProcessEnginee对象成功:" + processEngine);
	}

}



二、相应的Spring配置文件:



	
		
		
		
		
		
		
		
	



你可能感兴趣的:(Activiti学习)