We use the @Configuration classes to configure Spring-based Java. I am trying to create an AnnotationConfigApplicationContext (s) hierarchy.
It seems to have worked. Since I can Autowire beans from the parent context as beans members created from one of the child contexts.
However, I canβt manage Autowire beans from the parent context to the @Configuration class @Configuration , which is very convenient. All of them are equal to zero.
// parent context config @Configuration public class ParentContextConfig{ @Bean parentBeanOne... @Bean parentBeanTwo... }
// child context config @Configuration public class ChildContextConfig{ @Autowired parentBeanOne @Bean childBeanOne... }
// a sample bean @Component public class ChildBeanOne{ @Autowired parentBeanTwo }
In this example, I get parentBeanTwo correctly created, and parentBeanOne not auto-set ( null ) to the configuration file.
What am I missing?
Rafael
source share