I came across two annotations provided by Spring 3 (@Component and @Configuration)
I am a bit confused between these.
Here is what I read about @Component
Put this “context:component” in bean configuration file, it means, enable auto scanning feature in Spring. The base-package is indicate where are your components stored, Spring will scan this folder and find out the bean (annotated with @Component) and register it in Spring container.
So I am wondering what is the use of @Configuration then if @Controller will register my beans without the need to declare them in spring configuration xml file
From Book Pro Spring Integration
@Configuration
classes are just like regular @Components
classes, except that methods annotated with @Bean
are used to factory beans. Note that a @Component
with @Bean
annotated methods works the same way, except that scopes are not respected and the @Bean
methods are re-invoked (no caching in play), so @Configuration
is preferred, even though it requires CGLIB