Because of the project needs, I started to integrate the workflow engine Activiti in Project Spring boot. Because of the first integration, it was a pit step along the way, blaming me for not seeing the official documents first. We will now record the problems encountered on the road.
I. Environment configuration
1. Project Environment: Springboot2.0 + Maven + activiti6.0 + Eclipse
2.maven dependencies:
<Dependency>        <groupId>Org.activiti</groupId>        <Artifactid>Activiti-spring-boot-starter-basic</Artifactid>        <version>6.0.0</version>      </Dependency>      <Dependency>        <groupId>Org.springframework.boot</groupId>        <Artifactid>Spring-boot-starter-data-jpa</Artifactid>      </Dependency>      <Dependency>        <groupId>Mysql</groupId>        <Artifactid>Mysql-connector-java</Artifactid>      </Dependency>      <!--Unit Test -      <Dependency>        <groupId>Org.springframework.boot</groupId>        <Artifactid>Spring-boot-starter-test</Artifactid>        <Scope>Test</Scope>      </Dependency>
3. Install the Eclipse plugin: Activiti designer plugin; address: http://www.activiti.org/designer/update/
Two. Process examples
1.Spring Boot Project Startup class 
Import Org.activiti.spring.boot.securityautoconfiguration;import org.springframework.boot.SpringApplication; Import Org.springframework.boot.autoconfigure.springbootapplication;import Org.springframework.context.annotation.ComponentScan; @SpringBootApplication (exclude = Securityautoconfiguration.class) @ComponentScan (value = {"Com.river", "Com.river.learn"}) public class App {        public static void Main (string[] args) {        springapplication.run (app.class, args);}    }
2. Create a new directory under Src/main/resources: PROCESSES/MYPROCESSES.BPMN.
  
Note: There are several kinds of task icons, as above there are two, the connotation is different. Properties is a view that can be opened in Windows-a show view
 3. Write service interface for BPMN file invocation
  
       
@Service  Public class testservice {  publicvoid  Activiti () {System.out.println ("The task has been performed ...).    ........................"); }   public list<string> User () {  return arrays.aslist ("Xiaoming", "Xiaohong"    c11>); }}
 4. Write the test interface to test  
 PackageCom.river.learn;ImportJava.util.HashMap;Importjava.util.List;ImportJava.util.Map;ImportOrg.activiti.engine.RuntimeService;ImportOrg.activiti.engine.TaskService;Importorg.activiti.engine.runtime.ProcessInstance;ImportOrg.activiti.engine.task.Task;Importorg.junit.Test;ImportOrg.junit.runner.RunWith;Importorg.springframework.beans.factory.annotation.Autowired;Importorg.springframework.boot.test.context.SpringBootTest;ImportOrg.springframework.test.context.junit4.SpringJUnit4ClassRunner;ImportCom.river.learn.web.service.TestService;Importcom.river.main.App; the @RunWith (Springjunit4classrunner.class) @SpringBootTest (Classes= App.class, webenvironment =SpringBootTest.WebEnvironment.RANDOM_PORT) Public classactivititest {@Autowired testservice testservice;    @Autowired Runtimeservice Runtimeservice; @AutowiredPrivateTaskservice Taskservice; @Test Public voidteststartprocess () {System.out.println ("Start ...."); ProcessInstance Pi= Runtimeservice.startprocessinstancebykey ("Myprocess", "1"); System.out.println ("Process started successfully, Process ID:" +Pi.getid ()); } @Test Public voidFindtasksbyuserid () {String userId= "Dulingjiang"; List<Task> resulttask = Taskservice.createtaskquery (). Processdefinitionkey ("Myprocess"). taskcandidateorassigned (userId). List (); System.out.println ("Task List:" +resulttask); }}
 Start the test class and test it.
Three. Questions
Question one: caused By:java.lang.ArrayStoreException:sun.reflect.annotation.TypeNotPresentExceptionProxy
Solution : Project start on the report this error, tossing for a long time did not solve the problem, finally found a solution on a blog, but unfortunately forgot the author's blog link. The workaround is to add @SpringBootApplication (exclude = securityautoconfiguration.class) directly on the startup class. Securityautoconfiguration.class comes from the class org.activiti.spring.boot.SecurityAutoConfiguration. The first time I cited the wrong class, the problem was not resolved. I also think that my mistake is not solved by this method. Oh, careful.
  
 question two:Org.activiti.engine.ActivitiObjectNotFoundException:no processes deployed with key ' myprocess '
  Workaround: the console hints Runtimeservice.startprocessinstancebykey ("myprocess", map) does not have "myprocess", But my BPMN file in resource is "MYPROCESS.BPMN."
Change to lowercase: Runtimeservice.startprocessinstancebykey ("myprocess", map) succeeds, it seems that there is a rule in activiti, and the lowercase initials must be recognized.
  issue three:org.activiti.engine.ActivitiException:Could not execute service task expression
  Workaround: the task expression error configured in the MYPROCESS.BPMN file causes unresolved: The first letter in the expression should be lowercase, otherwise it will not be recognized. 
  
  question four:Org.activiti.engine.ActivitiException:Expression did not resolve to a string or collection of strings
  Workaround: I did not return a value when I wrote the interface method for the first time, so I got an error. The person who approves the node settings should return an array, otherwise it is wrong.
  
Cond......
Springboot Integrated Activiti All the way to the pit