2016-05-17 58 views
0

發生了什麼事每一個。你好嗎?我需要你的幫助activiti。我是新手,我試圖從activiti user guide實施activiti示例,但我的過程沒有部署......沒有錯誤,沒有任何東西。 我的Java代碼:無法部署流程activiti

public static void main(String[] args) { 
    // TODO Auto-generated method stub 
    ProcessEngine processEngine = null; 
    ProcessEngineConfiguration processConfig= null; 
    processConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault(); 

    processEngine = processConfig.buildProcessEngine(); 
    //Get Activiti services 
    RepositoryService repositoryService = processEngine.getRepositoryService(); 
    RuntimeService runtimeService = processEngine.getRuntimeService(); 

    //Deploy the process definition 
    repositoryService.createDeployment() 
     .addClasspathResource("diagrams/FinancialReportProcess.bpmn20.xml") 
     .deploy(); 
     System.out.println("Your process should be deployed..."); 

    //Start a process instance 
    runtimeService.startProcessInstanceByKey("financialReport"); 
     System.out.println("Your process should be started..."); 


    // Get the first task 
    TaskService taskService = processEngine.getTaskService(); 
    List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list(); 
    for (Task task : tasks) { 
     System.out.println("Following task is available for accountancy group: " + task.getName()); 

     // claim it 
     taskService.claim(task.getId(), "fozzie"); 
    } 

    // Verify Fozzie can now retrieve the task 
    tasks = taskService.createTaskQuery().taskAssignee("fozzie").list(); 
    for (Task task : tasks) { 
     System.out.println("Task for fozzie: " + task.getName()); 

     // Complete the task 
     taskService.complete(task.getId()); 
    } 

    System.out.println("Number of tasks for fozzie: " 
      + taskService.createTaskQuery().taskAssignee("fozzie").count()); 

    // Retrieve and claim the second task 
    tasks = taskService.createTaskQuery().taskCandidateGroup("management").list(); 
    for (Task task : tasks) { 
     System.out.println("Following task is available for management group: " + task.getName()); 
     taskService.claim(task.getId(), "kermit"); 
    } 

    // Completing the second task ends the process 
    for (Task task : tasks) { 
     taskService.complete(task.getId()); 
    } 
    } 

和我FinancialReportProcess.bpmn20.xml代碼:

<?xml version="1.0" encoding="UTF-8"?> 

<definitions id="definitions" 
    targetNamespace="http://activiti.org/bpmn20" 
    xmlns:activiti="http://activiti.org/bpmn" 
    xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"> 

<process id="financialReport" name="Monthly financial report reminder process"> 

    <startEvent id="theStart" /> 

    <sequenceFlow id='flow1' sourceRef='theStart' targetRef='writeReportTask' /> 

    <userTask id="writeReportTask" name="Write monthly financial report" > 
    <documentation> 
     Write monthly financial report for publication to shareholders. 
    </documentation> 
    <potentialOwner> 
     <resourceAssignmentExpression> 
     <formalExpression>accountancy</formalExpression> 
     </resourceAssignmentExpression> 
    </potentialOwner> 
    </userTask> 

    <sequenceFlow id='flow2' sourceRef='writeReportTask' targetRef='verifyReportTask' /> 

    <userTask id="verifyReportTask" name="Verify monthly financial report" > 
    <documentation> 
     Verify monthly financial report composed by the accountancy department. 
     This financial report is going to be sent to all the company shareholders. 
    </documentation> 
    <potentialOwner> 
     <resourceAssignmentExpression> 
     <formalExpression>management</formalExpression> 
     </resourceAssignmentExpression> 
    </potentialOwner> 
    </userTask> 

    <sequenceFlow id='flow3' sourceRef='verifyReportTask' targetRef='theEnd' /> 

    <endEvent id="theEnd" /> 

</process> 

</definitions> 

我有什麼來解決,這樣我就可以部署我的過程。 THX您的時間

回答

0

我想你應該初始化流程引擎這樣的,

的流程引擎的流程引擎= ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration() .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE) .setJdbcUrl( 「你的JDBC URL」) .setJdbcUsername( 「用戶名」) .setJdbcPassword( 「密碼」) .setAsyncExecutorEnabled(真) .setAsyncExecutorActivate(假) .buildProcessEngine();

+0

GJ老兄,但你怎麼知道的?你有沒有告訴我一個提示,我怎麼理解這些邏輯錯誤? –

+0

您正在創建一個沒有任何配置的流程引擎,例如數據庫連接,用戶名,密碼等......另一種方法是使用activiti.cfg.xml文件,您可以在其中指定流程引擎的配置。看看這個http://activiti.org/userguide/index.html#configuration –

+0

我永遠不知道在哪裏可以找到這個文件。我應該手動創建還是必須導入? –