简体   繁体   English

无法从根上下文自动装配子bean(在Web上下文中定义)

[英]Cannot autowire child bean (defined in a web context) from root context

I have a bean in the root context (ApplicationContext) which autowires another bean in a WebContext and it's throwing: 我在根上下文(ApplicationContext)中有一个bean,它在WebContext中自动装配另一个bean并且它正在抛出:

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pageFlowController': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.flex.messaging.MessageTemplate
com.biosds.gcfs.nassic.flow.PageFlowController.msgTemplate; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type
[org.springframework.flex.messaging.MessageTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Autowired(required=true)}

I'm trying to get a MessageTemplate in PageFlowController, where PageFlowController is defined in the root context and MessageTemplate in a web context. 我正在尝试在PageFlowController中获取MessageTemplate,其中PageFlowController在根上下文中定义,而MessageTemplate在Web上下文中定义。

A child context has access to beans in a parent context, but a parent context has no access to beans in a child context. 子上下文可以访问父上下文中的bean,但父上下文无权访问子上下文中的bean。

See the Spring Reference for more information. 有关更多信息,请参见Spring Reference

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring无法自动关联上下文中定义的Web服务Bean - Spring can't autowire webservice bean defined in context 根和子应用程序上下文中具有相同名称的Bean? - Bean with same name in Root and Child Application Context? Spring servletcontext无法在根应用程序上下文中访问bean - Spring servletcontext cannot access bean in root application context 春季3:将在xml应用程序上下文中声明的bean自动装配到@Component bean - Spring 3: Autowire a bean declared in xml application context to a @Component bean 在根上下文中定义的Spring MVC事务管理器不会在子上下文中定义的dao中打开事务 - Spring MVC transaction manager defined in root context doesn't open transactions in dao defined in child context 从根上下文访问Bean时出现Spring NoSuchBeanDefinitionException - Spring NoSuchBeanDefinitionException when accessing a bean from root context 将Web应用程序从默认根移到新上下文根 - Moving a web app from default root to new context root 如何从servlet上下文而不是根上下文中获取bean? - How can I get a bean from the servlet context instead of the root context? 在根上下文和servlet上下文中创建Spring控制器bean - Spring controller bean is created in root context AND in servlet context 不同Web模块的根上下文 - Root Context for different Web modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM