Hi,

can we dynamically add one existing bean into spring AnnotationConfigApplicationContext when we initialize the context?

e.g. I have this spring java config:
Code:
@Configuration
public class MyConfig {

  @Autowire public MyBean mybean;

  @Bean public AnotherBean another() {
     return new AnotherBean( mybean );
  }
}
Then, when I initialize AnnotationConfigApplicationContext, I want to dynamically add MyBean instance into context, e.g.
Code:
    MyBean mybean = createMyBean....
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()
    //context.add(mybean )  // so MyConfig below can autowire mybean instance
    context.register(classOf[MyConfig ])
Could you please let me know how I can add mybean instance to AnnotationConfigApplicationContext?

David