一 代码
package com.syc.activiti;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder;
public class ProcessDeploy {
public static void main( String[] args ) {
//创建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
//得到流程存储服务对象
RepositoryService repositoryService = engine.getRepositoryService();
//创建DeploymentBuilder实例
DeploymentBuilder builder = repositoryService.createDeployment();
builder.addClasspathResource("bpmn/processDeploy.bpmn").deploy();
}
}
二 流程文件
<?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: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" typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="vacationProcess" name="vacation">
<userTask id="usertask1" name="User Task"></userTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow2" name="" sourceRef="usertask1"
targetRef="endevent1"></sequenceFlow>
<startEvent id="startevent1" name="Start"></startEvent>
<sequenceFlow id="flow3" name="" sourceRef="startevent1"
targetRef="usertask1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_vacationProcess">
<bpmndi:BPMNPlane bpmnElement="vacationProcess"
id="BPMNPlane_vacationProcess">
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55" width="105" x="310" y="160"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35" width="35" x="490" y="170"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startevent1"
id="BPMNShape_startevent1">
<omgdc:Bounds height="35" width="35" x="170" y="170"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="415" y="187"></omgdi:waypoint>
<omgdi:waypoint x="490" y="187"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="205" y="187"></omgdi:waypoint>
<omgdi:waypoint x="310" y="187"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
三 运行后数据库
1 act_re_deployment
mysql> select * from act_re_deployment;
+-------+-------+-----------+------+------------+-------------------------+-----------------+
| ID_ | NAME_ | CATEGORY_ | KEY_ | TENANT_ID_ | DEPLOY_TIME_ | ENGINE_VERSION_ |
+-------+-------+-----------+------+------------+-------------------------+-----------------+
| 32501 | NULL | NULL | NULL | | 2020-04-18 09:38:38.271 | NULL |
+-------+-------+-----------+------+------------+-------------------------+-----------------+
1 row in set (0.00 sec)
2 act_re_procdef
mysql> select * from act_re_procdef;
+-------------------------+------+------------------------------+----------+-----------------+----------+----------------+-------------------------+----------------------------------------+--------------+---------------------+-------------------------+-------------------+------------+-----------------+
| ID_ | REV_ | CATEGORY_ | NAME_ | KEY_ | VERSION_ | DEPLOYMENT_ID_ | RESOURCE_NAME_ | DGRM_RESOURCE_NAME_ | DESCRIPTION_ | HAS_START_FORM_KEY_ | HAS_GRAPHICAL_NOTATION_ | SUSPENSION_STATE_ | TENANT_ID_ | ENGINE_VERSION_ |
+-------------------------+------+------------------------------+----------+-----------------+----------+----------------+-------------------------+----------------------------------------+--------------+---------------------+-------------------------+-------------------+------------+-----------------+
| vacationProcess:1:32504 | 1 | http://www.activiti.org/test | vacation | vacationProcess | 1 | 32501 | bpmn/processDeploy.bpmn | bpmn/processDeploy.vacationProcess.png | NULL | 0 | 1 | 1 | | NULL |
+-------------------------+------+------------------------------+----------+-----------------+----------+----------------+-------------------------+----------------------------------------+--------------+---------------------+-------------------------+-------------------+------------+-----------------+
1 row in set (0.00 sec)
3 act_ge_bytearray