1.添加依赖
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>6.4.2</version>
</dependency>
2.使用Test类创建23张表,数据库驱动根据自己使用的数据库选择,在创建表的时候如果数据库已经存在flowable的表需要在链接后面加上nullCatalogMeansCurrent=true
/**使用代码创建工作流需要的23张表*/
@Test
public void createTable() {
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration();
//连接数据库的配置
//配置数据库驱动:对应不同数据库类型的驱动
processEngineConfiguration.setJdbcDriver("com.mysql.cj.jdbc.Driver");
//配置数据库的JDBC URL
processEngineConfiguration.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true");
//配置连接数据库的用户名
processEngineConfiguration.setJdbcUsername("root");
//配置连接数据库的密码
processEngineConfiguration.setJdbcPassword("1qaz!QAZ");
/**
public static final String DB_SCHEMA_UPDATE_FALSE = "false";不能自动创建表,需要表存在
public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";先删除表再创建表
public static final String DB_SCHEMA_UPDATE_TRUE = "true";如果表不存在,自动创建表
*/
processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
//工作流的核心对象,ProcessEnginee对象
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
System.out.println("processEngine:"+processEngine);
}
3.使用Test类进行流程图的发布和查看,流程图放在resources可以识别
流程图https://download.csdn.net/download/qq_19897551/11878422
import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.ProcessDefinition;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
/**
* 工作流的业务测试
*
*