maven项目如下:
配置好数据库,和activiti的配置之后,开始执行流程部署
package com.yuanqiao.first_activiti.deployment;
import java.util.List;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.ProcessDefinition;
import org.junit.Test;
import com.google.gson.Gson;
/**
* 通过读取bpmn文件,来部署流程图
*
* @author yuanqiao
*
*/
public class DeploymentProcess {
@Test
public void deploymentFirstProcess() {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addClasspathResource("first.bpmn");
Deployment deployment = deploymentBuilder.deploy();
String deploymentId = deployment.getId();
System.out.println(deploymentId);
List processDefinitionList = repositoryService.createProcessDefinitionQuery()
.deploymentId(deploymentId).list();
Gson gson = new Gson();
System.out.println(gson.toJson(processDefinitionList));
}
}
报错如下:
[main] ERROR org.activiti.engine.impl.interceptor.CommandContext - Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table ‘activiti.act_ge_property‘ doesn‘t exist
### The error may exist in org/activiti/db/mapping/entity/Property.xml
### The error may involve org.activiti.engine.impl.persistence.entity.PropertyEntityImpl.selectProperty-Inline
### The error occurred while setting parameters
### SQL: select * from ACT_GE_PROPERTY where NAME_ = ?
### Cause: java.sql.SQLSyntaxErrorException: Table ‘activiti.act_ge_property‘ doesn‘t exist
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
at org.activiti.engine.impl.db.DbSqlSession.selectById(DbSqlSession.java:364)
at org.activiti.engine.impl.db.DbSqlSession.selectById(DbSqlSession.java:348)
at org.activiti.engine.impl.db.DbSqlSession.dbSchemaUpdate(DbSqlSession.java:910)
at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:1318)
at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:28)
at org.activiti.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:37)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:78)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:57)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:42)
at org.activiti.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:48)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:63)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:29)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:44)
at org.activiti.engine.impl.ProcessEngineImpl.(ProcessEngineImpl.java:81)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:665)
at org.activiti.engine.ProcessEngines.buildProcessEngine(ProcessEngines.java:189)
at org.activiti.engine.ProcessEngines.initProcessEngineFromResource(ProcessEngines.java:162)
at org.activiti.engine.ProcessEngines.init(ProcessEngines.java:94)
at org.activiti.engine.ProcessEngines.getProcessEngine(ProcessEngines.java:223)
at org.activiti.engine.ProcessEngines.getDefaultProcessEngine(ProcessEngines.java:212)
at com.yuanqiao.first_activiti.deployment.DeploymentProcess.deploymentFirstProcess(DeploymentProcess.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
解决方法:
(1)把mysql8.0的版本改成5.0的
mysql
mysql-connector-java
5.1.41
(2)修改驱动:
原文:https://www.cnblogs.com/mkl34367803/p/11570131.html