环境参照另一个博客中
@Test
public void testProcessDefinition() {
// 创建 Activiti流程引擎
ProcessEngine processEngine = ProcessEngineConfiguration.
createProcessEngineConfigurationFromResource("activiti.cfg.xml").
buildProcessEngine();
// 取得 Activiti 服务
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// 部署流程定义
Deployment deploy = repositoryService.createDeployment().
addClasspathResource("Interview.bpmn").deploy();
//查看定义的流程(非必须,只是验证流程定义是否部署成功)
System.out.println("deploy.getId():" + deploy.getId()); //数字:1
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.deploymentId(deploy.getId()).singleResult();
System.out.println("processDefinition.getKey():"+processDefinition.getKey()); //process中id的值,自定义的: Interview
// 启动流程实例
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinition.getKey());
System.out.println("pid="+processInstance.getId()+",pdid="+
processInstance.getProcessDefinitionId()); //pid=4,pdid=Interview:1:3
}