开启流程实例并注入变量
/** * 开启流程实例并为流程注入map * @author Administrator * */ public class Test01 { public static void main(String[] args) { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); //创建map Map<String,Object> map = new HashMap<String,Object>(); map.put("name", "苹果"); map.put("age", 24); //开启流程实例 ProcessInstance pi = processEngine.getRuntimeService() .startProcessInstanceByKey("上学的流程key"); //得到流程实例id System.out.println(pi.getProcessInstanceId()); //得到流程实例的id String piid = pi.getProcessInstanceId(); //为这个流程实例设置局部变量 名字为 vars processEngine.getRuntimeService() .setVariable(piid, "vars", map); } }