with reference to the below example, Autowiring Unmanaged Beans Annotated With @Component It states that you are required to register the bean in xml file and then only you can wire it in your Java class, even though you have used context:component-scan. But the example Difference between context:annotation-config vs context:component-scan [see example with highest up votes (174)] states that you can wire the beans without having its definition in the xml file..
so i got confused which is correct definition ?? I actually tried and got exception as described in the first url (Autowiring unmanaged beans). If we assume that bean definition is required in xml file then what is the real advantage or difference between <context:annotation-config>
and <context:component-scan>
.
I found both the links contradicting each other