我正在尝试使用Activiti eclipse BPMN Designer 5.9创建一个简单的Hello world应用程序。我在Eclipse中创建了一个activiti项目,并将我的check.bpmn图添加到src / main / resources文件夹中,并将.java添加到src / test / java,并将activiti.cfg.xml文件添加到src / test / resources文件夹中。该应用程序只是假设向控制台显示警报“ Hello”,但是我似乎无法做到这一点。下面是我用于运行该应用程序的所有文件。我不知道我缺少什么。我已经安装了Activiti Eclipse BPMN 2.0设计器。

更新:

我已经添加了jar文件
java -  eclipse 激活中的BPMN错误-LMLPHP

错误:

java -  eclipse 激活中的BPMN错误-LMLPHP
POM.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.activiti.examples</groupId>
  <artifactId>activiti-examples</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>BPMN 2.0 with Activiti - Examples</name>
  <properties>
    <activiti-version>5.8</activiti-version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.activiti</groupId>
      <artifactId>activiti-engine</artifactId>
      <version>${activiti-version}</version>
    </dependency>
    <dependency>
      <groupId>org.activiti</groupId>
      <artifactId>activiti-spring</artifactId>
      <version>${activiti-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>1.7.5</version>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.2.132</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
    </dependency>
  </dependencies>
     <repositories>
    <repository>
      <id>Activiti</id>
      <url>http://maven.alfresco.com/nexus/content/repositories/activiti</url>
       </repository>
     </repositories>
     <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
           <version>2.3.2</version>
        <configuration>
             <source>1.6</source>
             <target>1.6</target>
           </configuration>
         </plugin>
         <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <inherited>true</inherited>
        <configuration>
             <classpathContainers>
               <classpathContainer>org.eclipse.jdt.USER_LIBRARY/Activiti Designer Extensions</classpathContainer>
             </classpathContainers>
           </configuration>
         </plugin>
    </plugins>
     </build>
</project>


Check.bpmn:

<?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="process1" name="process1">
    <startEvent id="startevent1" name="Start"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript">
      <script><![CDATA[alert("hello");]]></script>
    </scriptTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_process1">
    <bpmndi:BPMNPlane bpmnElement="process1" id="BPMNPlane_process1">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="200" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55" width="105" x="280" y="150"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="440" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="235" y="177"></omgdi:waypoint>
        <omgdi:waypoint x="280" y="177"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="385" y="177"></omgdi:waypoint>
        <omgdi:waypoint x="440" y="177"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


ProcessTestProcess1.java

package org.activiti.designer.test;

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;
import java.io.FileInputStream;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.test.ActivitiRule;
import org.junit.Rule;
import org.junit.Test;

public class ProcessTestProcess1 {

    private String filename = "C:\Users\User\workspace\Proj\src\main\resources\diagrams\Check.bpmn";

    @Rule
    public ActivitiRule activitiRule = new ActivitiRule();

    @Test
    public void startProcess() throws Exception {
        RepositoryService repositoryService = activitiRule.getRepositoryService();
        repositoryService.createDeployment().addInputStream("process1.bpmn20.xml",
                new FileInputStream(filename)).deploy();
        RuntimeService runtimeService = activitiRule.getRuntimeService();
        Map<String, Object> variableMap = new HashMap<String, Object>();
        variableMap.put("name", "Activiti");
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
        assertNotNull(processInstance.getId());
        System.out.println("id " + processInstance.getId() + " "
                + processInstance.getProcessDefinitionId());
    }
}


错误:

Description Resource    Path    Location    Type
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 9  Java Problem
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 10 Java Problem
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 11 Java Problem
The import org.activiti.engine cannot be resolved   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 12 Java Problem
The import org.activiti cannot be resolved  Main.java   /helloworld/src/main/java   line 1  Java Problem
The import org.activiti cannot be resolved  Main.java   /helloworld/src/main/java   line 2  Java Problem
The import org.activiti cannot be resolved  Main.java   /helloworld/src/main/java   line 3  Java Problem
RuntimeService cannot be resolved to a type ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 28 Java Problem
RepositoryService cannot be resolved to a type  ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 25 Java Problem
ProcessService cannot be resolved to a type Main.java   /helloworld/src/main/java   line 13 Java Problem
ProcessInstance cannot be resolved to a type    ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 31 Java Problem
ProcessEngine cannot be resolved to a type  Main.java   /helloworld/src/main/java   line 10 Java Problem
Invalid escape sequence (valid ones are  \b  \t  \n  \f  \r  \"  \'  \\ )   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 18 Java Problem
DbProcessEngineBuilder cannot be resolved to a type Main.java   /helloworld/src/main/java   line 10 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 21 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 21 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 25 Java Problem
ActivitiRule cannot be resolved to a type   ProcessTestProcess1.java    /Proj/src/test/java/org/activiti/designer/test  line 28 Java Problem

最佳答案

错误


  无效的转义序列(有效的是\ b \ t \ n \ f \ r \“ \'\)


告诉您您的字符串无效。

private String filename = "C:\Users\User\workspace\Proj\src\main\resources\diagrams\Check.bpmn";


应该逃脱

private String filename = "C:\\Users\\User etc...";

关于java - eclipse 激活中的BPMN错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38736235/

10-11 04:05