This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Shasi Mitra wrote:You can give this <context:component-scan base-package="org.example"/> . Now, all your beans in the package will be instantiated.
As long as you are using @Component or one of its stereotype annotations.
@Component replaces the need for <bean> tags
@Autowired replaces the need for <property> or <constructor-arg> tags.
Usually you use both, but you don't have to.
You can use just @Autowired without any @Component, then in that scenario you will need <bean> tags for all the classes. Also, with this scenario you don't use component-scan, or need it, you use <context:annotation-config> instead.