我想在spring mvc中使用activiti。我的java配置为activiti在下面。
当我运行项目时,此异常no processes deployed with key
抛出。我把one-vacation-process.bpmn20.xml
放在资源文件夹中。我的问题是什么?谢谢你的帮助。
@Configuration
public class ActivitiConfig {
@Bean
public ProcessEngine processEngine(ProcessEngineConfigurationImpl pec, ApplicationContext applicationContext) throws Exception {
ProcessEngineFactoryBean pe = new ProcessEngineFactoryBean();
pe.setProcessEngineConfiguration(pec);
pe.setApplicationContext(applicationContext);
return pe.getObject();
}
@Bean
public ProcessEngineConfigurationImpl getProcessEngineConfiguration(
DataSource dataSource,
PlatformTransactionManager transactionManager,
ApplicationContext context) {
SpringProcessEngineConfiguration pec = new SpringProcessEngineConfiguration();
pec.setDataSource(dataSource);
pec.setDatabaseSchemaUpdate("true");
pec.setJobExecutorActivate(true);
pec.setHistory("full");
pec.setMailServerPort(2025);
pec.setDatabaseType("mysql");
pec.setTransactionManager(transactionManager);
pec.setApplicationContext(context);
return pec;
}
@Bean
public RuntimeService getRuntimeService(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}
@Bean
public TaskService taskService(ProcessEngine processEngine) throws Exception {
return processEngine.getTaskService();
}
答案 0 :(得分:1)
您需要先部署流程。
有针对不同用例的API,在这里我部署了一个进程,其中resourceName
是进程xml的名称(例如one-vacation-process.bpmn20.xml
),content
实际文件内容为字符串。< / p>
RepositoryService repositoryService = processEngine.getRepositoryService();
DeploymentBuilder builder = repositoryService.createDeployment().addString(resourceName, content);
builder.enableDuplicateFiltering().deploy();
请查看org.activiti.engine.repository.DeploymentBuilder
哪里有API,如:
DeploymentBuilder addInputStream(String resourceName, InputStream inputStream);
DeploymentBuilder addClasspathResource(String resource);
DeploymentBuilder addString(String resourceName, String text);
DeploymentBuilder addZipInputStream(ZipInputStream zipInputStream);
DeploymentBuilder addBpmnModel(String resourceName, BpmnModel bpmnModel);