简体   繁体   中英

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:

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.

A child context has access to beans in a parent context, but a parent context has no access to beans in a child context.

See the Spring Reference for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM