difference between @Component and @Configuration in Spring 3

后端 未结 5 1855
悲哀的现实
悲哀的现实 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:14

    @Component is a generic stereotype annotation which can indicate any of the candidate components i.e; @Repository, @Service, @Controller and these candidates are eligible for auto-detection.

    Where as @Configuration is used to create component which is used by spring framework to create the application context, internally @Configuration makes use of @Component it makes sense reason being even that's a spring component which the framework itself creates.

提交回复
热议问题