问题:
Can @Component
, @Repository
and @Service
annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? @Repository
@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://stackoom.com/question/SeD2/Spring中的-Component-Repository和-Service批注有什么区别参考二: https://oldbug.net/q/SeD2/What-s-the-difference-between-Component-Repository-Service-annotations-in-Spring
来源:oschina
链接:https://my.oschina.net/u/4432649/blog/4467416