AnnotationConfigApplicationContext has not been refreshed yet - what's wrong?
You have to call ctx.refresh()
before you can call ctx.getBean(HelloWorld.class);
If you dont want to call ctx.refresh()
explicitly, just initialize ApplicationContext like this:
new AnnotationConfigApplicationContext(MyConfig.class)
, then configuration will be registered and refreshed implicitly