Difference between Spring annotations

前端 未结 5 1517
说谎
说谎 2020-12-04 11:08

Questions:

1) Difference between @Component and @Configuration?

I have read that both remove the necessity of

5条回答
  •  春和景丽
    2020-12-04 11:57

    On the difference between @Autowired, @Inject and @Resource you can look here. Here you can thorough description and comparison.

    What concerns the first difference: @Configuration is used as replacement for XML-based configuration, ie. it marks classes as the ones used for Java-based configuration, see here. In turn, @Component is actually used to mark classes as the ones to be instantiated by Spring and @Configuration is meta-annotated by @Component annotation.

    @Component and @Configuration serve different purposes so it doesn't make sense to compare them.

提交回复
热议问题