行业知识
Spring中的注释
2026-11-27 12:01:17
来源:互联网转载
@Resource注释
@Resourceprivate AService aService;
This annotation may be applied to an application component class, or to fields or methods of the component class. When the annotation is applied to a field or method, the container will inject an instance of the requested resource into the application component when the component is initialized. If the annotation is applied to the component class, the annotation declares a resource that the application will look up at runtime.
()1.给组件类注释:如Service类:声明一个应用程序在运行时会持续检查的资源;
2.给组件类的字段或者方法注释:当组件初始化的时候,容器会注入要求资源的实例到应用程序;
()上一篇:怎么登录服务器的软件下载?
下一篇:云部署服务器便宜sd