# 设置流程引擎启动和关闭时数据库执行的策略
# false:false为默认值,设置为该值后,Activiti在启动时,会对比数据库表中保存的版本,如果版本不匹配时,将在启动时抛出异常。
# true:设置为该值后,Activiti会对数据库中所有的表进行更新,如果表不存在,则Activiti会自动创建。
# create-drop:Activiti启动时,会执行数据库表的创建操作,在Activiti关闭时,执行数据库表的删除操作。
# drop-create:Activiti启动时,执行数据库表的删除操作在Activiti关闭时,会执行数据库表的创建操作。
spring.activiti.database-schema-update=true
第三步:application.properties中添加mysql连接配置:
因为activiti运行要有一套自己的表来交互,所以一定要配置数据库。
这里要注意我这里用的是最新的mysql版本8.0.11数据源url一定要拼时区
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://localhost:3306/study?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
#spring.datasource.username=root(你数据库用户名)
#spring.datasource.password=root(你数据库密码)
第四步:resource目录下创建processes目录并创建一个bpmn流程定义文件
这里可以直接创建一个bpmn后缀的文件,copy下面的内容黏贴进去保存就好。这个改怎么写就自己慢慢研究吧,也可以后面装个插件直接画好生成出来。
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/testm1510735932336" id="m1510735932336" name="">
<process id="leave" isExecutable="true" isClosed="false" processType="None">
<startEvent id="_2" name="StartEvent"></startEvent>
<endEvent id="_3" name="EndEvent"></endEvent>
<userTask id="approve" name="经理审批" activiti:assignee="${approve}"></userTask>
<exclusiveGateway id="_5" name="ExclusiveGateway"></exclusiveGateway>
<sequenceFlow id="_6" sourceRef="approve" targetRef="_5"></sequenceFlow>
<sequenceFlow id="_7" name="通过" sourceRef="_5" targetRef="_3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${pass}]]></conditionExpression>
</sequenceFlow>
<userTask id="application" name="提交申请" activiti:assignee="${apply}"></userTask>
<sequenceFlow id="_9" sourceRef="_2" targetRef="application"></sequenceFlow>
<sequenceFlow id="_10" sourceRef="application" targetRef="approve"></sequenceFlow>
<userTask id="modify" name="修改申请" activiti:assignee="${apply}"></userTask>
<sequenceFlow id="_12" name="不通过" sourceRef="_5" targetRef="modify">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!pass}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_13" sourceRef="modify" targetRef="approve"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_leave">
<bpmndi:BPMNPlane bpmnElement="leave" id="BPMNPlane_leave">
<bpmndi:BPMNShape bpmnElement="_2" id="BPMNShape__2">
<omgdc:Bounds height="35.0" width="35.0" x="15.0" y="60.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="BPMNShape__3">
<omgdc:Bounds height="35.0" width="35.0" x="630.0" y="63.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="approve" id="BPMNShape_approve">
<omgdc:Bounds height="55.0" width="85.0" x="315.0" y="50.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="BPMNShape__5">
<omgdc:Bounds height="40.0" width="40.0" x="505.0" y="60.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="application" id="BPMNShape_application">
<omgdc:Bounds height="55.0" width="85.0" x="135.0" y="50.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="modify" id="BPMNShape_modify">
<omgdc:Bounds height="55.0" width="85.0" x="315.0" y="150.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6">
<omgdi:waypoint x="400.0" y="77.0"></omgdi:waypoint>
<omgdi:waypoint x="505.0" y="80.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7">
<omgdi:waypoint x="545.0" y="80.0"></omgdi:waypoint>
<omgdi:waypoint x="630.0" y="80.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9">
<omgdi:waypoint x="50.0" y="77.0"></omgdi:waypoint>
<omgdi:waypoint x="135.0" y="77.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10">
<omgdi:waypoint x="220.0" y="77.0"></omgdi:waypoint>
<omgdi:waypoint x="315.0" y="77.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12">
<omgdi:waypoint x="525.0" y="100.0"></omgdi:waypoint>
<omgdi:waypoint x="525.0" y="177.0"></omgdi:waypoint>
<omgdi:waypoint x="400.0" y="177.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13">
<omgdi:waypoint x="357.0" y="150.0"></omgdi:waypoint>
<omgdi:waypoint x="357.0" y="105.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
第五步:当然是写helloworld 了
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("activityService")
public class ActivityServiceImpl implements ActivityService {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private RepositoryService repositoryService;
@Override
public boolean startActivityDemo() {
System.out.println("method startActivityDemo begin....");
System.out.println("调用流程存储服务,查询部署数量:" + repositoryService.createDeploymentQuery().count());
Map<String, Object> map = new HashMap<String, Object>();
map.put("apply", "大都督17918");
map.put("approve", "大统领");
//流程启动
ExecutionEntity pi1 = (ExecutionEntity) runtimeService.startProcessInstanceByKey("leave", map);
List<Task> tasks = taskService.createTaskQuery().taskAssignee("zhangsan").list();
System.out.println(tasks.size());
//当前任务办理人
String assignee = "大都督一起加油";
//创建一个任务查询对象
List<Task> taskList = taskService.createTaskQuery().taskAssignee(assignee).list();
if (! CollectionUtils.isEmpty(taskList)) {
for (Task task : tasks) {
System.out.println("-------------------------------------");
System.out.println("任务ID:" + task.getId());
System.out.println("任务的办理人:" + task.getAssignee());
System.out.println("任务名称:" + task.getName());
System.out.println("任务的创建时间:" + task.getCreateTime());
System.out.println("流程实例ID:" + task.getProcessInstanceId());
System.out.println("-------------------------------------");
System.out.println("method startActivityDemo end....");
return false;
第六步:启动程序调用demo程序运行如下
method startActivityDemo begin....
调用流程存储服务,查询部署数量:1
-------------------------------------
任务ID:2507
任务的办理人:zhangsan
任务名称:提交申请
任务的创建时间:Tue Jun 02 01:09:30 CST 2020
流程实例ID:2501
-------------------------------------
method startActivityDemo end....
OK 到此整合就完成了
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5...
因为springboot首推的连接池使用了HikariCP连接池,GET到这个点, HikariDataSource的获取数据库连接的getConnection方法
修改application.properties:
spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/mypydb
spring.datasource2.jdbc-url=j...
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'actModelController': Unsatisfied dependency expressed through field 'repositoryService'; nested exception is org.springframework.beans.factory.UnsatisfiedDepen
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.clas
今天项目依赖了一个基础组件之后,启动失败,排查过程走了一些弯路,最终确认是因为依赖组件版本冲突造成了java.lang.NoClassDefFoundError异常。下面是排查过程,希望可以给你提供一些思路。
观察异常栈
下面是打印的异常栈信息,从其中提炼可能的关键信息,能够找到“Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]”,还有“Unresolvable c
1.问题描述
在我引入SpringCloud-gateway,运行时报错如下:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routeDefinitionRouteLocator' define...
异常如下:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'persistenceExceptionTranslationPostProcessor' defined in class path resource [org/springframework/boo