What's the difference between @Component, @Repository & @Service annotations in Spring?

問題:

Can @Component , @Repository and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? @Component@Repository@Service註釋可以在 Spring 中互換使用嗎,或者除了充當註釋設備之外,它們是否還提供任何特定的功能?

In other words, if I have a Service class and I change the annotation from @Service to @Component , will it still behave the same way?換句話說,如果我有一個 Service 類並且我將註釋從@Service更改爲@Component ,它的行爲是否仍然相同?

Or does the annotation also influence the behavior and functionality of the class?或者註釋是否也會影響類的行爲和功能?


解決方案:

參考一: https://en.stackoom.com/question/SeD2
參考二: https://stackoom.com/question/SeD2
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章