Spring中的@ Component,@ Repository和@Service批注有什么区别?

放肆的年华 提交于 2020-08-14 02:08:15

问题:

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!