我正在遵循tutorial来使用JAVA在Alfresco上操作nodeRef和内容。但是当我尝试定义serviceRegistry
时,
ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
beanFactory
未初始化。我已经尝试了很多声明,但无法正确初始化/声明。谁能帮我?我尝试:
ApplicationContext appContext = new ClassPathXmlApplicationContext("alfresco/web-client-application-context.xml");
ServiceRegistry serviceRegistry =(ServiceRegistry)appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
web-client-application-context.xml:
https://github.com/Alfresco/community-edition/blob/master/projects/web-client/config/alfresco/web-client-application-context.xml
错误:
org.springframework.beans.factory.BeanCreationException:错误
在类中创建名称为“ GlobalAuthenticationFilter”的bean
路径资源[alfresco / web-client-application-context.xml]:无法
设置bean属性时解析对bean'Authentication'的引用
'applicationContextManager';嵌套异常为
org.springframework.beans.factory.NoSuchBeanDefinitionException:否
定义了名为“身份验证”的bean
另一种方式?我该如何解决?
最佳答案
我用以下替代方法解决了它:ServiceRegistry serviceRegistry = (ServiceRegistry) beanFactory.getBean(ServiceRegistry.SERVICE_REGISTRY);
为了这:
protected ServiceRegistry getServiceRegistry() {
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
if (config != null) {
// Fetch the registry that is injected in the activiti spring-configuration
ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
if (registry == null) {
throw new RuntimeException("Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
}
return registry;
}
throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
}
关于java - 错误beanFactory/ApplicationContext-JAVA,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33837637/