Java 在spring boot 2.0.4中嵌入jbpm 7.9时的循环依赖关系
我试图将jbpm 7.9嵌入到spring boot项目中,我遵循了[official documentation][1]中的说明,但没有像文档中那样使用xml配置,而是使用spring Java配置类。配置类如图所示Java 在spring boot 2.0.4中嵌入jbpm 7.9时的循环依赖关系,java,spring-boot,jbpm,kie,Java,Spring Boot,Jbpm,Kie,我试图将jbpm 7.9嵌入到spring boot项目中,我遵循了[official documentation][1]中的说明,但没有像文档中那样使用xml配置,而是使用spring Java配置类。配置类如图所示 @Configuration public class JBPMConfiguration { @Bean public PropertiesFactoryBean roleProperties() { PropertiesFactoryBean
@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;
}
}
请删除所有@DependsOn和(initMethod=“onInit”)。 我的演示工作正常,但它们不是processService的参数,因为runtimeDataService和deploymentService在同一个类中,与其他方法相同 检查此源代码:
***************************
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]
└─────┘
org.jbpm.kie.services.impl.utils.DefaultKieServiceConfigurator.java#configureServices