【发布时间】:2018-08-08 17:20:49
【问题描述】:
我正在尝试将 jbpm 7.9 嵌入到 Spring Boot 项目中,我已按照 [官方文档][1] 中的说明进行操作,但我没有像文档中那样使用 xml 配置,而是使用 Spring Java 配置班级。配置类如图
@Configuration
public class JBPMConfiguration {
@Bean
public PropertiesFactoryBean roleProperties() {
PropertiesFactoryBean bean = new PropertiesFactoryBean();
bean.setLocation(new ClassPathResource("roles.properties"));
return bean;
}
@Bean
public JBossUserGroupCallbackImpl userGroupCallback(Properties roleProperties) {
return new JBossUserGroupCallbackImpl(roleProperties);
}
@Bean
public ClearBPMSecurityIdentityProvider identityProvider() {
return new ClearBPMSecurityIdentityProvider();
}
@Bean
public SpringRuntimeManagerFactoryImpl runtimeManagerFactory(JtaTransactionManager transactionManager,
JBossUserGroupCallbackImpl userGroupCallback) {
SpringRuntimeManagerFactoryImpl springRuntimeManagerFactoryImpl = new SpringRuntimeManagerFactoryImpl();
springRuntimeManagerFactoryImpl.setTransactionManager(transactionManager);
springRuntimeManagerFactoryImpl.setUserGroupCallback(userGroupCallback);
return springRuntimeManagerFactoryImpl;
}
@Bean
public TransactionalCommandService transactionCmdService(EntityManagerFactory entityManagerFactory) {
return new TransactionalCommandService(entityManagerFactory);
}
@Bean(destroyMethod = "close")
public TaskServiceFactoryBean taskService(EntityManagerFactory entityManagerFactory,
JtaTransactionManager transactionManager, UserGroupCallback userGroupCallback) {
TaskServiceFactoryBean taskServiceFactoryBean = new TaskServiceFactoryBean();
taskServiceFactoryBean.setEntityManagerFactory(entityManagerFactory);
taskServiceFactoryBean.setTransactionManager(transactionManager);
taskServiceFactoryBean.setUserGroupCallback(userGroupCallback);
TaskLifeCycleEventListener taskLifeCycleEventListener = new JPATaskLifeCycleEventListener(true);
List<TaskLifeCycleEventListener> list = new ArrayList<>();
list.add(taskLifeCycleEventListener);
taskServiceFactoryBean.setListeners(list);
return taskServiceFactoryBean;
}
@Bean
public BPMN2DataServiceImpl definitionService() {
return new BPMN2DataServiceImpl();
}
@Bean
public RuntimeDataServiceImpl runtimeDataService(TransactionalCommandService transactionCmdService,
ClearBPMSecurityIdentityProvider identityProvider, TaskServiceFactoryBean taskService) throws Exception {
RuntimeDataServiceImpl runtimeDataServiceImpl = new RuntimeDataServiceImpl();
runtimeDataServiceImpl.setCommandService(transactionCmdService);
runtimeDataServiceImpl.setIdentityProvider(identityProvider);
runtimeDataServiceImpl.setTaskService((TaskService) taskService.getObject());
return runtimeDataServiceImpl;
}
@Bean(initMethod = "onInit")
@DependsOn("entityManagerFactory")
public KModuleDeploymentService deploymentService(DefinitionService definitionService,
EntityManagerFactory entityManagerFactory, RuntimeManagerFactory runtimeManagerFactory,
IdentityProvider identityProvider, RuntimeDataService runtimeDataService) {
KModuleDeploymentService kModuleDeploymentService = new KModuleDeploymentService();
kModuleDeploymentService.setBpmn2Service(definitionService);
kModuleDeploymentService.setEmf(entityManagerFactory);
kModuleDeploymentService.setManagerFactory(runtimeManagerFactory);
kModuleDeploymentService.setIdentityProvider(identityProvider);
kModuleDeploymentService.setRuntimeDataService(runtimeDataService);
return kModuleDeploymentService;
}
@Bean
@DependsOn(value = { "deploymentService" })
public ProcessServiceImpl processService(RuntimeDataService runtimeDataService,
DeploymentService deploymentService) {
ProcessServiceImpl processService = new ProcessServiceImpl();
processService.setDataService(runtimeDataService);
processService.setDeploymentService(deploymentService);
return processService;
}
@Bean
@DependsOn(value = { "deploymentService" })
public UserTaskServiceImpl userTaskService(RuntimeDataService runtimeDataService,
DeploymentService deploymentService) {
UserTaskServiceImpl userTaskService = new UserTaskServiceImpl();
userTaskService.setDataService(runtimeDataService);
userTaskService.setDeploymentService(deploymentService);
return userTaskService;
}
@Bean
@DependsOn(value = { "deploymentServices"})
public MethodInvokingFactoryBean data(RuntimeDataService runtimeDataService, DeploymentService deploymentService) {
MethodInvokingFactoryBean methodInvokingFactoryBean = new MethodInvokingFactoryBean();
methodInvokingFactoryBean.setTargetObject(deploymentService);
methodInvokingFactoryBean.setTargetMethod("addListener");
ArrayList<RuntimeDataService> arrayList = new ArrayList<>();
arrayList.add(runtimeDataService);
methodInvokingFactoryBean.setArguments(arrayList);
return methodInvokingFactoryBean;
}
}
服务器未启动,出现以下错误,请帮助
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
userGroupCallback defined in class path resource [tv/clearhub/bpm/configuration/JBPMConfiguration.class]
┌─────┐
| taskService defined in class path resource [tv/clearhub/bpm/configuration/JBPMConfiguration.class]
↑ ↓
| data defined in class path resource [tv/clearhub/bpm/configuration/JBPMConfiguration.class]
↑ ↓
| runtimeDataService defined in class path resource [tv/clearhub/bpm/configuration/JBPMConfiguration.class]
└─────┘
【问题讨论】:
标签: java spring-boot jbpm kie