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.
Mark