This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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.