difference between @Component and @Configuration in Spring 3

后端 未结 5 1858
悲哀的现实
悲哀的现实 2020-12-02 21:48

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

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 22:04

    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

提交回复
热议问题