問題:
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