⼯作流引擎flowable学习----idea创建maven请假流程例⼦1.创建简单maven项⽬
2.添加依赖
选择项⽬下的l⽂件,打开,加上⽅框⾥代码
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
3.在项⽬test->src->resources中添加⽇志⽂件log4j.properties,写⼊该内容Logger=DEBUG, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n
4.新建flowable的表
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()
.setJdbcUrl("jdbc:mysql://localhost:3306/flowable")
.setJdbcUsername("root")
.setJdbcPassword("root")
.setJdbcDriver("sql.jdbc.Driver")
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
ProcessEngine processEngine = cfg.buildProcessEngine();
运⾏后表⽬录为
5.使⽤flowable创建⼀个简单的请假流程
5.1创建⼀个bpmn⽂件:l,将其放置于/src/main/resources下
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="/spec/BPMN/20100524/MODEL"
xmlns:xsi="/2001/XMLSchema-instance"
xmlns:xsd="/2001/XMLSchema"
xmlns:bpmndi="/spec/BPMN/20100524/DI"
xmlns:omgdc="/spec/DD/20100524/DC"
xmlns:omgdi="/spec/DD/20100524/DI"
xmlns:activiti="/bpmn"
typeLanguage="/2001/XMLSchema"
expressionLanguage="/1999/XPath"
targetNamespace="/processdef">
<process id="holidayRequest" name="Holiday Request" isExecutable="true">
<startEvent id="startEvent"/>
idea debug<sequenceFlow sourceRef="startEvent" targetRef="approveTask"/>
<userTask id="approveTask" name="Approve or reject request" activiti:candidateGroups="managers"/>
<sequenceFlow sourceRef="approveTask" targetRef="decision"/>
<exclusiveGateway id="decision"/>
<sequenceFlow sourceRef="decision" targetRef="externalSystemCall">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[
${approved}
]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow  sourceRef="decision" targetRef="sendRejectionMail">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[
${!approved}
]]>
</conditionExpression>
</sequenceFlow>
<!--cn.test.first.CallExternalSystemDelegate是你的包-->
<serviceTask id="externalSystemCall" name="Enter holidays in external system" activiti:class="cn.test.first.CallExternalSystemDelegate"/>        <sequenceFlow sourceRef="externalSystemCall" targetRef="holidayApprovedTask"/>
<userTask id="holidayApprovedTask" name="Holiday approved" activiti:assignee="${employee}"/>
<sequenceFlow sourceRef="holidayApprovedTask" targetRef="approveEnd"/>
<!--cn.test.first.SendRejectionMail是你的包-->
<serviceTask id="sendRejectionMail" name="Send out rejection email" activiti:class="cn.test.first.SendRejectionMail"/>
<sequenceFlow sourceRef="sendRejectionMail" targetRef="rejectEnd"/>
<endEvent id="approveEnd"/>
<endEvent id="rejectEnd"/>
</process>
</definitions>
5.2部署写好的BPMN2.0⽂件:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。