{"id":96,"date":"2024-05-28T18:19:16","date_gmt":"2024-05-28T10:19:16","guid":{"rendered":"https:\/\/www.tqazy.com\/?p=96"},"modified":"2024-05-28T18:19:16","modified_gmt":"2024-05-28T10:19:16","slug":"autowired","status":"publish","type":"post","link":"https:\/\/www.tqazy.com\/?p=96","title":{"rendered":"@Autowired"},"content":{"rendered":"<h1>@Autowired<\/h1>\n<h2>\u6982\u5ff5<\/h2>\n<p><code>@Autowired<\/code> \u662fSpring\u6846\u67b6\u63d0\u4f9b\u7684\u6ce8\u89e3\uff0c\u7528\u4e8e\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u3002<\/p>\n<p>\u5b83\u6839\u636e\u7c7b\u578b\u9a71\u52a8\uff0c\u7c7b\u578b\u81ea\u52a8\u5339\u914d\u5e76\u6ce8\u5165Bean\u3002<\/p>\n<p>Spring\u5bb9\u5668\u8d1f\u8d23\u5728\u8fd0\u884c\u65f6\u89e3\u6790 <code>@Autowired<\/code> \u6ce8\u89e3\uff0c\u81ea\u52a8\u5c06\u4f9d\u8d56\u7684Bean\u6ce8\u5165\u5230\u9700\u8981\u5b83\u4eec\u7684\u7ec4\u4ef6\u4e2d\u3002<\/p>\n<p>\u6b64\u6ce8\u89e3\u53ef\u4ee5\u5e94\u7528\u4e8e\u5b57\u6bb5\u3001\u65b9\u6cd5\u548c\u6784\u9020\u51fd\u6570\u4e0a\uff0c\u652f\u6301\u901a\u8fc7\u7c7b\u578b\u5339\u914d\u3001\u9650\u5b9a\u7b26\uff08\u5982 <code>@Qualifier<\/code> \uff09\u4ee5\u53ca\u6309\u540d\u79f0\u5339\u914d\u7b49\u591a\u79cd\u7b56\u7565\u6765\u786e\u5b9a\u5177\u4f53\u7684\u4f9d\u8d56\u9879\u3002<\/p>\n<h2>\u901a\u4fd7\u8bf4\u6cd5<\/h2>\n<p>\u60f3\u8c61\u4e00\u4e0b\uff0c\u4f60\u5f00\u4e86\u4e00\u5bb6\u9762\u5305\u5e97\uff0c\u6bcf\u5929\u9700\u8981\u4e00\u5b9a\u91cf\u7684\u9762\u7c89\u6765\u5236\u4f5c\u9762\u5305\u3002<code>@Autowired<\/code> \u5c31\u50cf\u662f\u4e00\u4e2a\u81ea\u52a8\u5316\u7684\u4f9b\u5e94\u94fe\u7cfb\u7edf\uff0c\u5b83\u77e5\u9053\u4f60\u5e97\u91cc\u9700\u8981\u9762\u7c89\uff0c\u4e0d\u9700\u8981\u4f60\u4eb2\u81ea\u8dd1\u5230\u5e02\u573a\u6311\u9009\uff0c\u800c\u662f\u81ea\u52a8\u5e2e\u4f60\u628a\u9762\u7c89\u9001\u5230\u53a8\u623f\u91cc\u3002\u8fd9\u6837\uff0c\u4f60\u53ea\u9700\u8981\u544a\u8bc9\u7cfb\u7edf\u201c\u6211\u9700\u8981\u9762\u7c89\u201d\uff0c\u5269\u4e0b\u7684\u4e8b\u60c5\u7cfb\u7edf\u4f1a\u5e2e\u4f60\u641e\u5b9a\u3002<\/p>\n<p>\u6bd4\u5982\uff0c\u4f60\u7684\u9762\u5305\u5e97\u6709\u4e00\u4e2a\u505a\u9762\u56e2\u7684\u673a\u5668\uff08\u4e00\u4e2a\u7c7b\uff09\uff0c\u8fd9\u4e2a\u673a\u5668\u9700\u8981\u9762\u7c89\uff08\u53e6\u4e00\u4e2a\u7c7b\u7684\u670d\u52a1\uff09\u3002\u4f7f\u7528 <code>@Autowired<\/code> \u5c31\u50cf\u7ed9\u8fd9\u4e2a\u673a\u5668\u8d34\u4e86\u4e00\u4e2a\u6807\u7b7e\uff0c\u5199\u7740\u201c\u8bf7\u81ea\u52a8\u7ed9\u6211\u9001\u9762\u7c89\u6765\u201d\u3002Spring\u6846\u67b6\u5c31\u50cf\u662f\u770b\u61c2\u8fd9\u4e2a\u6807\u7b7e\u7684\u914d\u9001\u5458\uff0c\u4f1a\u5728\u9762\u5305\u5e97\u5f00\u95e8\uff08\u5e94\u7528\u542f\u52a8\uff09\u524d\uff0c\u786e\u4fdd\u9762\u7c89\u5df2\u7ecf\u653e\u5728\u673a\u5668\u65c1\u8fb9\u4e86\u3002<\/p>\n<p>\u540c\u65f6\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528 <code>@Qualifier<\/code> \u6ce8\u89e3\u9650\u5b9a\u540d\u79f0\u5339\u914d\uff0c\u5c31\u50cf\u5728\u6807\u7b7e\u5199\u201c\u6211\u9700\u8981\u7684\u662f\u4f4e\u7b4b\u5c0f\u9ea6\u9762\u7c89\u201d \u3002<\/p>\n<h2>\u6240\u5c5e<\/h2>\n<p>Spring\u6846\u67b6\u3002<\/p>\n<blockquote>\n<p>import org.springframework.beans.factory.annotation.Autowired;<\/p>\n<\/blockquote>\n<h2>\u4f5c\u7528<\/h2>\n<p>\u81ea\u52a8\u88c5\u914dBean\uff0c\u51cf\u5c11XML\u914d\u7f6e\u6216\u663e\u5f0fsetter\u65b9\u6cd5\u8c03\u7528\u3002<\/p>\n<p>\u5b83\u53ef\u4ee5\u5728\u7c7b\u7684\u6784\u9020\u51fd\u6570\u3001\u6210\u5458\u53d8\u91cf\u3001setter\u65b9\u6cd5\u548c\u65b9\u6cd5\u53c2\u6570\u4e0a\u4f7f\u7528\u3002<\/p>\n<h2>\u7528\u6cd5<\/h2>\n<ul>\n<li>\u5b57\u6bb5\u6ce8\u5165:\n<pre><code class=\"language-java\">@Autowired \nprivate MyService myService;<\/code><\/pre>\n<\/li>\n<li>\u6784\u9020\u5668\u6ce8\u5165:\n<pre><code class=\"language-java\">public MyClass(@Autowired MyService myService) {\n    this.myService = myService;\n}<\/code><\/pre>\n<\/li>\n<li>setter\uff08\u65b9\u6cd5\uff09\u6ce8\u5165:\n<pre><code class=\"language-java\">@Autowired \npublic void setMyService(MyService myService) {\n    this.myService = myService;\n}<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>\u4f7f\u7528\u573a\u666f<\/h2>\n<p>\u9002\u5408\u4e8e\u5f53\u4f9d\u8d56\u5173\u7cfb\u660e\u786e\u4e14\u5355\u4e00\uff0c\u6216\u8005\u9700\u8981\u786e\u4fdd\u4f9d\u8d56\u9879\u5728\u5bf9\u8c61\u521b\u5efa\u65f6\u5c31\u5b8c\u5168\u521d\u59cb\u5316\u7684\u573a\u666f\u3002<\/p>\n<h2>\u5bf9\u6bd4 <a href=\"@Resource.md\"><code>@Resource<\/code><\/a> \u4f7f\u7528\u8fd9\u4e24\u4e2a\u6ce8\u89e3\u7684\u4f18\u7f3a\u70b9<\/h2>\n<h3>@Autowired<\/h3>\n<p><strong>\u4f18\u70b9:<\/strong><\/p>\n<ul>\n<li>\u7c7b\u578b\u9a71\u52a8\uff0c\u7b80\u5316\u914d\u7f6e\uff0c\u901a\u5e38\u53ea\u9700\u5173\u6ce8\u7c7b\u578b\u5339\u914d\u5373\u53ef\u3002<\/li>\n<li>\u652f\u6301\u6784\u9020\u5668\u3001\u5b57\u6bb5\u3001\u65b9\u6cd5\u548c\u53c2\u6570\u7ea7\u522b\u7684\u6ce8\u5165\uff0c\u4f7f\u7528\u7075\u6d3b\u3002<\/li>\n<li>\u5f3a\u5236\u4f9d\u8d56\u9879\u7684\u5b58\u5728\uff0c\u6709\u52a9\u4e8e\u8bbe\u8ba1\u66f4\u5065\u58ee\u7684\u4ee3\u7801\u7ed3\u6784\u3002<\/li>\n<\/ul>\n<p><strong>\u7f3a\u70b9:<\/strong><\/p>\n<ul>\n<li>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u652f\u6301\u540d\u79f0\u5339\u914d\uff0c\u5f53\u6709\u591a\u4e2a\u76f8\u540c\u7c7b\u578b\u7684Bean\u65f6\u53ef\u80fd\u9020\u6210\u6b67\u4e49\u3002<\/li>\n<li>\u9690\u85cf\u4e86\u4f9d\u8d56\u5173\u7cfb\uff0c\u4e0d\u5982\u6784\u9020\u5668\u6ce8\u5165\u660e\u663e\uff0c\u53ef\u80fd\u964d\u4f4e\u4ee3\u7801\u53ef\u8bfb\u6027\u3002<\/li>\n<li>\u6d4b\u8bd5\u65f6\uff0c\u9700\u8981\u6a21\u62df\u4f9d\u8d56\u65f6\u53ef\u80fd\u8f83\u4e3a\u7e41\u7410\u3002<\/li>\n<\/ul>\n<h3>@Resource<\/h3>\n<p><strong>\u4f18\u70b9:<\/strong><\/p>\n<ul>\n<li>\u652f\u6301\u540d\u79f0\u5339\u914d\uff0c\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u7075\u6d3b\u6027\uff0c\u7279\u522b\u9002\u5408\u4e8e\u89e3\u51b3\u4f9d\u8d56\u51b2\u7a81\u6216\u9700\u8981\u7279\u5b9a\u547d\u540d\u7ea6\u5b9a\u7684\u60c5\u51b5\u3002<\/li>\n<li>\u7531\u4e8e\u662fJava EE\u6807\u51c6\uff0c\u56e0\u6b64\u5177\u6709\u66f4\u597d\u7684\u8de8\u6846\u67b6\u517c\u5bb9\u6027\u3002<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9aname\u5c5e\u6027\u7cbe\u786e\u63a7\u5236\u6ce8\u5165\u7684Bean\u3002<\/li>\n<\/ul>\n<p><strong>\u7f3a\u70b9:<\/strong><\/p>\n<ul>\n<li>\u9ed8\u8ba4\u6309\u540d\u79f0\u5339\u914d\uff0c\u53ef\u80fd\u5bfc\u81f4\u5728\u672a\u660e\u786e\u6307\u5b9a\u540d\u79f0\u65f6\uff0c\u4f9d\u8d56\u6ce8\u5165\u7684\u610f\u56fe\u4e0d\u5982\u7c7b\u578b\u9a71\u52a8\u660e\u786e\u3002<\/li>\n<li>\u9ed8\u8ba4required\u5c5e\u6027\u4e3afalse\uff0c\u610f\u5473\u7740\u5982\u679c\u6ca1\u6709\u5339\u914d\u7684Bean\uff0c\u8be5\u6ce8\u89e3\u4f1a\u88ab\u5ffd\u7565\uff0c\u8fd9\u53ef\u80fd\u5f15\u5165\u6f5c\u5728\u7684\u9519\u8bef\u6216\u6df7\u6dc6\u3002<\/li>\n<li>\u4e0d\u5982 <code>@Autowired<\/code> \u90a3\u6837\u5e7f\u6cdb\u96c6\u6210\u4e8eSpring\u6846\u67b6\u7684\u5176\u4ed6\u7279\u6027\u4e2d\uff0c\u53ef\u80fd\u5728\u4e00\u4e9b\u9ad8\u7ea7\u529f\u80fd\u4e0a\u652f\u6301\u4e0d\u8db3\u3002<\/li>\n<\/ul>\n<h2>\u4e3e\u4f8b\u8bf4\u660e\u201c\u7c7b\u578b\u9a71\u52a8\u201d\u548c\u201c\u540d\u79f0\u5339\u914d\u201d<\/h2>\n<h3>1. \u7c7b\u578b\u9a71\u52a8<\/h3>\n<p>\u7c7b\u578b\u9a71\u52a8\u5339\u914d\u5c31\u50cf\u662f\u5728\u5496\u5561\u5e97\u70b9\u5496\u5561\uff0c\u4f60\u8bf4\uff1a\u201c\u6211\u8981\u4e00\u676f\u62ff\u94c1\u3002\u201d<\/p>\n<p>\u65e0\u8bba\u54ea\u4f4d\u5496\u5561\u5e08\u5728\u5427\u53f0\uff0c\u53ea\u8981\u4f60\u70b9\u7684\u662f\u62ff\u94c1\uff0c\u4ed6\u4eec\u90fd\u77e5\u9053\u600e\u4e48\u5236\u4f5c\uff0c\u4f60\u4e0d\u5728\u4e4e\u662f\u54ea\u4e00\u4f4d\u5496\u5561\u5e08\u4e3a\u4f60\u670d\u52a1\uff0c\u4f60\u5728\u4e4e\u7684\u662f\u5f97\u5230\u4e00\u676f\u62ff\u94c1\u3002<\/p>\n<p>\u8fd9\u91cc\u7684\u201c\u62ff\u94c1\u201d\u5c31\u662f\u7c7b\u578b\uff0c\u4f60\u4f9d\u9760\u7c7b\u578b\u6765\u83b7\u5f97\u60f3\u8981\u7684\u4ea7\u54c1\uff0c\u800c\u4e0d\u5173\u5fc3\u5177\u4f53\u7684\u63d0\u4f9b\u8005\u662f\u8c01\u3002<\/p>\n<p><strong>\u4ee3\u7801\u6f14\u793a<\/strong><\/p>\n<p>\u60f3\u8c61\u6211\u4eec\u6709\u4e24\u4e2a\u5b9e\u73b0\u4e86\u76f8\u540c\u63a5\u53e3\u7684Service\u7c7b\uff0c\u5206\u522b\u662f <code>EmailService<\/code> \u548c <code>SmsService<\/code> \uff0c\u800c\u6211\u4eec\u7684 <code>Controller<\/code> \u9700\u8981\u6ce8\u5165\u4e00\u4e2a\u5b9e\u73b0\u8be5\u63a5\u53e3\u7684\u670d\u52a1\u3002<\/p>\n<pre><code class=\"language-java\">public interface MessageService {\n    void sendMessage(String message);\n}\n\n@Service(&quot;emailService&quot;)\npublic class EmailServiceImpl implements MessageService {\n    \/\/ \u5b9e\u73b0\u7ec6\u8282\n}\n\n@Service(&quot;smsService&quot;)\npublic class SmsServiceImpl implements MessageService {\n    \/\/ \u5b9e\u73b0\u7ec6\u8282\n}\n\n@Controller\npublic class MessageController {\n    @Autowired\n    private MessageService messageService; \/\/ \u7c7b\u578b\u9a71\u52a8\u6ce8\u5165\uff0cSpring\u4f1a\u6839\u636e\u7c7b\u578b\u627e\u5230\u4e00\u4e2a\u5408\u9002\u7684MessageService Bean\u6ce8\u5165\n}<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cSpring\u4f1a\u81ea\u52a8\u6839\u636e\u7c7b\u578b <code>MessageService<\/code> \u627e\u5230\u4e00\u4e2a\u5408\u9002\u7684Bean\u6ce8\u5165\u5230 <code>messageService<\/code> \u5b57\u6bb5\u3002<\/p>\n<p>\u5047\u8bbe\u6ca1\u6709\u7279\u522b\u914d\u7f6e\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u540d\u5b57\u4e14\u53ea\u6709\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0cSpring\u4f1a\u81ea\u52a8\u6ce8\u5165\u3002\u5982\u679c\u6709\u591a\u4e2a\u5b9e\u73b0\u7c7b\u4e14\u6ca1\u6709\u6307\u5b9a\u540d\u5b57\uff0c\u53ef\u80fd\u4f1a\u629b\u51fa\u5f02\u5e38\u6216\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u914d\u7f6e\u6765\u89e3\u51b3\u6b67\u4e49\u3002<\/p>\n<h3>2. \u540d\u79f0\u5339\u914d<\/h3>\n<p>\u540d\u79f0\u5339\u914d\u5219\u50cf\u662f\u5728\u9910\u5385\u9884\u8ba2\u5ea7\u4f4d\uff0c\u4f60\u8bf4\uff1a\u201c\u6211\u60f3\u9884\u8ba2\u9760\u7a97\u6709\u98ce\u666f\u7684\u20181\u53f7\u684c\u2019\u3002\u201d<\/p>\n<p>\u8fd9\u91cc\uff0c\u201c1\u53f7\u684c\u201d\u662f\u7279\u5b9a\u7684\u540d\u79f0\uff0c\u4f60\u6307\u5b9a\u4e86\u4e00\u4e2a\u5177\u4f53\u7684\u4f4d\u7f6e\uff0c\u800c\u4e0d\u662f\u8bf4\u201c\u6211\u60f3\u8981\u4e00\u5f20\u684c\u5b50\u201d\u3002\u9910\u5385\u4f1a\u6839\u636e\u8fd9\u4e2a\u540d\u5b57\u627e\u5230\u90a3\u4e2a\u7279\u5b9a\u5e8f\u53f7\u7684\u3001\u6709\u98ce\u666f\u89c2\u8d4f\u4f18\u52bf\u7684\u684c\u5b50\u7ed9\u4f60\u9884\u7559\uff0c\u800c\u4e0d\u662f\u968f\u4fbf\u5b89\u6392\u4e00\u5f20\u684c\u5b50\u3002<\/p>\n<p><strong>\u4ee3\u7801\u6f14\u793a<\/strong><\/p>\n<p>\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5728 <code>MessageController<\/code> \u4e2d\u660e\u786e\u6307\u5b9a\u4f7f\u7528\u54ea\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>@Qualifier<\/code> \u6ce8\u89e3\u914d\u5408 <code>@Autowired<\/code> \u3002<\/p>\n<pre><code class=\"language-java\">@Controller\npublic class MessageController {\n    @Autowired\n    @Qualifier(&quot;emailService&quot;) \/\/ \u540d\u79f0\u5339\u914d\uff0c\u6307\u5b9a\u6ce8\u5165\u540d\u4e3aemailService\u7684Bean\n    private MessageService messageService;\n}<\/code><\/pre>\n<p>\u6216\u8005\u4f7f\u7528 <code>@Resource<\/code> \u6ce8\u89e3\u5b9e\u73b0\u540d\u79f0\u5339\u914d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728\u6ce8\u89e3\u4e2d\u6307\u5b9aBean\u7684\u540d\u79f0\u3002<\/p>\n<pre><code class=\"language-java\">@Controller\npublic class MessageController {\n    @Resource(name = &quot;emailService&quot;) \/\/ \u540d\u79f0\u5339\u914d\uff0c\u6307\u5b9a\u6ce8\u5165\u540d\u4e3aemailService\u7684Bean\n    private MessageService messageService;\n}<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>@Resource<\/code> \u6ce8\u89e3\u53d6\u4ee3\u4e86 <code>@Autowired<\/code> + <code>@Qualifier<\/code> \u7684\u7ec4\u5408\u3002<\/p>\n<p>\u901a\u8fc7\u5728 <code>@Resource<\/code> \u6ce8\u89e3\u4e2d\u6dfb\u52a0 <code>name<\/code> \u5c5e\u6027\u5e76\u8bbe\u7f6e\u4e3a <code>&quot;emailService&quot;<\/code> \uff0c\u6211\u4eec\u6307\u5b9a\u4e86\u8981\u6ce8\u5165\u7684Bean\u7684\u540d\u79f0\uff0c\u5b9e\u73b0\u4e86\u4e0e\u4e4b\u524d\u4f7f\u7528 <code>@Qualifier<\/code> \u76f8\u540c\u7684\u529f\u80fd\u3002 <code>@Resource<\/code> \u6ce8\u89e3\u6e90\u81eaJava EE\u89c4\u8303\uff0c\u5b83\u5141\u8bb8\u6839\u636e\u540d\u79f0\u6216\u6309\u7c7b\u578b\uff08\u9ed8\u8ba4\u884c\u4e3a\uff09\u8fdb\u884c\u6ce8\u5165\uff0c\u5f53\u6307\u5b9a\u4e86 <code>name<\/code> \u5c5e\u6027\u65f6\uff0c\u5b83\u5c31\u6309\u7167\u540d\u79f0\u5339\u914d\u7684\u65b9\u5f0f\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>@Autowired \u6982\u5ff5 @Autowired \u662fSpring\u6846\u67b6\u63d0\u4f9b\u7684\u6ce8\u89e3\uff0c\u7528\u4e8e\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u3002 \u5b83\u6839\u636e\u7c7b\u578b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[43],"class_list":["post-96","post","type-post","status-publish","format-standard","hentry","category-42","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>@Autowired | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tqazy.com\/?p=96\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"@Autowired | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"@Autowired \u6982\u5ff5 @Autowired \u662fSpring\u6846\u67b6\u63d0\u4f9b\u7684\u6ce8\u89e3\uff0c\u7528\u4e8e\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u3002 \u5b83\u6839\u636e\u7c7b\u578b [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tqazy.com\/?p=96\" \/>\n<meta property=\"og:site_name\" content=\"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-28T10:19:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/05\/20240530090910445.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"\u9676\u5176\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u9676\u5176\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tqazy.com\/?p=96#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=96\"},\"author\":{\"name\":\"\u9676\u5176\",\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\"},\"headline\":\"@Autowired\",\"datePublished\":\"2024-05-28T10:19:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=96\"},\"wordCount\":39,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\"},\"keywords\":[\"\u6ce8\u89e3\"],\"articleSection\":[\"\u6ce8\u89e3\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tqazy.com\/?p=96#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tqazy.com\/?p=96\",\"url\":\"https:\/\/www.tqazy.com\/?p=96\",\"name\":\"@Autowired | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"https:\/\/www.tqazy.com\/#website\"},\"datePublished\":\"2024-05-28T10:19:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=96#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tqazy.com\/?p=96\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tqazy.com\/?p=96#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.tqazy.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"@Autowired\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tqazy.com\/#website\",\"url\":\"https:\/\/www.tqazy.com\/\",\"name\":\"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\",\"description\":\"\u5f53\u4e0b\uff0c\u5373\u662f\u672a\u6765\",\"publisher\":{\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\"},\"alternateName\":\"TaoQi's Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.tqazy.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\",\"name\":\"\u9676\u5176\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg\",\"contentUrl\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg\",\"width\":940,\"height\":940,\"caption\":\"\u9676\u5176\"},\"logo\":{\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/\"},\"description\":\"\u4e00\u4e2a\u5f88\u61d2\u7684\u7a0b\u5e8f\u5458\",\"sameAs\":[\"https:\/\/www.tqazy.com\"],\"url\":\"https:\/\/www.tqazy.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"@Autowired | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.tqazy.com\/?p=96","og_locale":"zh_CN","og_type":"article","og_title":"@Autowired | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","og_description":"@Autowired \u6982\u5ff5 @Autowired \u662fSpring\u6846\u67b6\u63d0\u4f9b\u7684\u6ce8\u89e3\uff0c\u7528\u4e8e\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u3002 \u5b83\u6839\u636e\u7c7b\u578b [&hellip;]","og_url":"https:\/\/www.tqazy.com\/?p=96","og_site_name":"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","article_published_time":"2024-05-28T10:19:16+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/05\/20240530090910445.jpg","type":"image\/jpeg"}],"author":"\u9676\u5176","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u9676\u5176","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tqazy.com\/?p=96#article","isPartOf":{"@id":"https:\/\/www.tqazy.com\/?p=96"},"author":{"name":"\u9676\u5176","@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e"},"headline":"@Autowired","datePublished":"2024-05-28T10:19:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.tqazy.com\/?p=96"},"wordCount":39,"commentCount":0,"publisher":{"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e"},"keywords":["\u6ce8\u89e3"],"articleSection":["\u6ce8\u89e3"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.tqazy.com\/?p=96#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.tqazy.com\/?p=96","url":"https:\/\/www.tqazy.com\/?p=96","name":"@Autowired | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.tqazy.com\/#website"},"datePublished":"2024-05-28T10:19:16+00:00","breadcrumb":{"@id":"https:\/\/www.tqazy.com\/?p=96#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.tqazy.com\/?p=96"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.tqazy.com\/?p=96#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.tqazy.com\/"},{"@type":"ListItem","position":2,"name":"@Autowired"}]},{"@type":"WebSite","@id":"https:\/\/www.tqazy.com\/#website","url":"https:\/\/www.tqazy.com\/","name":"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","description":"\u5f53\u4e0b\uff0c\u5373\u662f\u672a\u6765","publisher":{"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e"},"alternateName":"TaoQi's Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.tqazy.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e","name":"\u9676\u5176","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/","url":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg","contentUrl":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg","width":940,"height":940,"caption":"\u9676\u5176"},"logo":{"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/"},"description":"\u4e00\u4e2a\u5f88\u61d2\u7684\u7a0b\u5e8f\u5458","sameAs":["https:\/\/www.tqazy.com"],"url":"https:\/\/www.tqazy.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=96"}],"version-history":[{"count":0,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}