activiti no processes deployed with key ""

最近用activiti做一个很简单的小例子,自我感觉哪里都没问题,但是就是报:

org.activiti.engine.ActivitiObjectNotFoundException: no processes deployed with key 'myprocess' 

的错误,最后查资料终于找到了原因,那就是 activiti 的模版必须以  bpmn20.xml  或者 bpmn结尾;

代码如下:

目录结构:

AvtivitiAction


public class AvtivitiAction {


    @Test
    public void startProcess(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();

        DeploymentBuilder builder = repositoryService.createDeployment();
        builder.addClasspathResource("leave.bpmn20.xml");
        builder.deploy();
        // select * from `ACT_GE_PROPERTY`;这时这个表中会多条数据

        List<ProcessDefinition> p = repositoryService.createProcessDefinitionQuery().list();
        for(int i=0;i<p.size();i++){
            System.out.println(p.get(i).getKey());
        }
        RuntimeService runtimeService = processEngine.getRuntimeService();
        runtimeService.startProcessInstanceByKey("myProcess");//启动流程,ID必须与你配置的一致

        System.out.println("ok......");
    }
}


activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">
   <bean id="processEngineConfiguration"
        class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
      <property name="databaseSchemaUpdate" value="false" />
      <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/qsfs" />
      <property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
      <property name="jdbcUsername" value="qsfs" />
      <property name="jdbcPassword" value="qsfs" />
      <property name="jobExecutorActivate" value="true" />
   </bean>
</beans>

leave.bpmn20.xml

<?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/processdef">


    <process id="myProcess" name="leave" >
        <startEvent id="startevent" name="start"></startEvent>
        <endEvent id="endevent" name="end"></endEvent>
        <sequenceFlow id="flowid" name="flowname" sourceRef="startevent" targetRef="endevent"></sequenceFlow>
    </process>

</definitions>


转载于:https://my.oschina.net/u/1169535/blog/603969

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值