{"id":75200,"date":"2026-02-11T18:33:29","date_gmt":"2026-02-11T10:33:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/75200.html"},"modified":"2026-02-11T18:33:29","modified_gmt":"2026-02-11T10:33:29","slug":"%e9%9d%9e-spring-%e7%ae%a1%e7%90%86%e5%af%b9%e8%b1%a1%e8%8e%b7%e5%8f%96-spring-bean","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/75200.html","title":{"rendered":"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean"},"content":{"rendered":"<h3>\u4e00\u3001\u6559\u7a0b\u5f15\u8a00<\/h3>\n<p>\u5728 Spring Boot \u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u4e60\u60ef\u4e86\u901a\u8fc7&#064;Autowired\/&#064;Resource\u7b49\u6ce8\u89e3\u8f7b\u677e\u6ce8\u5165\u4f9d\u8d56 Bean&#xff0c;\u4f46\u5728 WebSocket\u3001\u5b9a\u65f6\u4efb\u52a1\u3001\u7b2c\u4e09\u65b9\u6846\u67b6\u5b9e\u4f8b\u5316\u5bf9\u8c61\u7b49\u573a\u666f\u4e0b&#xff0c;\u4f1a\u9047\u5230\u4e00\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u975e Spring \u521b\u5efa\u7684\u5bf9\u8c61\u65e0\u6cd5\u76f4\u63a5\u6ce8\u5165 Spring Bean\u3002<\/p>\n<p>\u672c\u6559\u7a0b\u5c06\u62c6\u89e3\u8fd9\u4e00\u95ee\u9898\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u5e76\u8bb2\u89e3\u4e00\u79cd\u7ecf\u5178\u7684\u89e3\u51b3\u65b9\u6848 \u2014\u2014\u300c\u501f\u58f3\u6ce8\u5165 &#043; \u9759\u6001\u5171\u4eab\u300d&#xff0c;\u5e2e\u52a9\u4f60\u7406\u89e3\u5176\u6838\u5fc3\u539f\u7406\u5e76\u638c\u63e1\u5b9e\u6218\u7528\u6cd5<\/p>\n<h3>\u4e8c\u3001\u6838\u5fc3\u95ee\u9898\u5256\u6790<\/h3>\n<h4>1. \u573a\u666f\u518d\u73b0&#xff1a;WebSocket \u65e0\u6cd5\u6ce8\u5165 Bean<\/h4>\n<p>\u5f53\u4f7f\u7528 WebSocket \u65f6&#xff0c;\u5176\u5b9e\u4f8b\u901a\u5e38\u7531 Tomcat\/Jetty \u7b49\u5bb9\u5668\u901a\u8fc7new\u5173\u952e\u5b57\u521b\u5efa&#xff08;\u800c\u975e Spring&#xff09;&#xff0c;\u6b64\u65f6\u76f4\u63a5\u5728 WebSocketServer \u4e2d\u6ce8\u5165 Mapper\/Service \u4f1a\u5931\u8d25&#xff1a;<\/p>\n<p>\/\/ \u9519\u8bef\u793a\u4f8b&#xff1a;\u975eSpring\u521b\u5efa\u7684\u5b9e\u4f8b\u65e0\u6cd5\u6ce8\u5165Bean<br \/>\npublic class WebSocketServer {<br \/>\n    \/\/ \u8fd0\u884c\u65f6\u4f1a\u62a5\u7a7a\u6307\u9488&#xff1a;Spring\u4e0d\u4f1a\u7ed9new\u51fa\u6765\u7684\u5bf9\u8c61\u6ce8\u5165\u4f9d\u8d56<br \/>\n    &#064;Autowired<br \/>\n    private UserMapper userMapper;<\/p>\n<p>    \/\/ WebSocket\u6838\u5fc3\u65b9\u6cd5&#xff0c;\u7531\u6846\u67b6\u8c03\u7528<br \/>\n    public void onMessage(String msg) {<br \/>\n        \/\/ userMapper\u4e3anull&#xff0c;\u629b\u51faNullPointerException<br \/>\n        userMapper.insertMessage(msg);<br \/>\n    }<br \/>\n}<\/p>\n<h4>2. \u95ee\u9898\u6839\u6e90&#xff1a;\u4e24\u4e2a\u6838\u5fc3\u89c4\u5219<\/h4>\n<p>\u8981\u89e3\u51b3\u95ee\u9898&#xff0c;\u5fc5\u987b\u5148\u7406\u89e3 Spring \u548c Java \u7684\u4e24\u4e2a\u5e95\u5c42\u89c4\u5219&#xff08;\u6838\u5fc3\u6982\u5ff5&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\n<p>\u6838\u5fc3\u6982\u5ff5<\/p>\n<p>\u89c4\u5219\u63cf\u8ff0\u901a\u4fd7\u7c7b\u6bd4<\/tr>\n<tbody>\n<tr>\n<td>Spring Bean \u8bbf\u95ee\u6743\u9650<\/td>\n<td>\u53ea\u6709 Spring \u81ea\u5df1\u521b\u5efa\u7684\u5bf9\u8c61&#xff08;\u6807\u6ce8 &#064;Component\/&#064;Service \u7b49&#xff09;&#xff0c;\u624d\u80fd\u901a\u8fc7 &#064;Autowired \u83b7\u53d6\u5bb9\u5668\u5185\u7684 Bean<\/td>\n<td>\u516c\u53f8\u540e\u52e4\u90e8\u53ea\u7ed9\u6b63\u5f0f\u5458\u5de5&#xff08;Spring \u521b\u5efa\u7684\u5bf9\u8c61&#xff09;\u53d1\u95e8\u7981\u5361&#xff08;Bean&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9759\u6001\u53d8\u91cf\u7c7b\u7ea7\u5171\u4eab<\/td>\n<td>static \u4fee\u9970\u7684\u5b57\u6bb5\u5c5e\u4e8e\u300c\u7c7b\u672c\u8eab\u300d&#xff0c;\u800c\u975e\u67d0\u4e2a\u5b9e\u4f8b&#xff1b;\u6240\u6709\u8be5\u7c7b\u7684\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4e2a\u9759\u6001\u53d8\u91cf<\/td>\n<td>\u6574\u680b\u697c\u7684\u516c\u5171\u996e\u6c34\u673a&#xff08;\u9759\u6001\u53d8\u91cf&#xff09;&#xff0c;\u6240\u6709\u623f\u95f4&#xff08;\u5b9e\u4f8b&#xff09;\u90fd\u80fd\u63a5\u6c34<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e09\u3001\u89e3\u51b3\u65b9\u6848&#xff1a;\u501f\u58f3\u6ce8\u5165 &#043; \u9759\u6001\u5171\u4eab<\/h3>\n<h4>1. \u65b9\u6848\u6838\u5fc3\u601d\u8def<\/h4>\n<p>\u901a\u8fc7&#064;Component\u8ba9 Spring \u521b\u5efa\u4e00\u4e2a\u300c\u5de5\u5177\u4eba\u5b9e\u4f8b\u300d\u5b8c\u6210\u4f9d\u8d56\u6ce8\u5165&#xff0c;\u518d\u5c06\u6ce8\u5165\u7684 Bean \u5b58\u5165\u9759\u6001\u53d8\u91cf&#xff08;\u7c7b\u7ea7\u5171\u4eab\u7a7a\u95f4&#xff09;&#xff0c;\u6700\u7ec8\u8ba9\u6240\u6709\u975e Spring \u5b9e\u4f8b\u4ece\u9759\u6001\u53d8\u91cf\u4e2d\u83b7\u53d6\u4f9d\u8d56\u3002<\/p>\n<h4>2. \u5206\u6b65\u5b9e\u73b0<\/h4>\n<h5>\u6b65\u9aa4 1&#xff1a;\u7ed9 WebSocketServer \u6dfb\u52a0 &#064;Component \u6ce8\u89e3&#xff08;\u501f\u58f3&#xff09;<\/h5>\n<p>\u7ed9 WebSocketServer \u7c7b\u6807\u6ce8&#064;Component&#xff0c;\u8ba9 Spring \u626b\u63cf\u5e76\u521b\u5efa\u4e00\u4e2a\u300c\u5de5\u5177\u4eba\u5b9e\u4f8b\u300d&#xff08;\u8be5\u5b9e\u4f8b\u4ec5\u7528\u4e8e\u89e6\u53d1\u6ce8\u5165&#xff0c;\u4e0d\u4f1a\u88ab\u5b9e\u9645\u4e1a\u52a1\u4f7f\u7528&#xff09;&#xff1a;<\/p>\n<p>&#064;Component \/\/ \u5173\u952e&#xff1a;\u8ba9Spring\u626b\u63cf\u5e76\u521b\u5efa\u5de5\u5177\u4eba\u5b9e\u4f8b<br \/>\npublic class WebSocketServer {<br \/>\n    \/\/ \u9759\u6001\u5b57\u6bb5&#xff1a;\u7c7b\u7ea7\u5171\u4eab\u7684&#034;\u516c\u5171\u4ed3\u5e93&#034;<br \/>\n    private static UserMapper userMapper;<\/p>\n<p>    \/\/ \u666e\u901a\u6210\u5458\u53d8\u91cf&#xff1a;\u4ec5\u7528\u4e8e\u63a5\u6536Spring\u6ce8\u5165\u7684Bean<br \/>\n    &#064;Autowired<br \/>\n    private UserMapper tempUserMapper;<\/p>\n<p>    \/\/ \u6ce8\u5165\u5b8c\u6210\u540e&#xff0c;\u5c06Bean\u5b58\u5165\u9759\u6001\u5b57\u6bb5<br \/>\n    &#064;PostConstruct \/\/ \u66ff\u4ee3setter&#xff0c;\u521d\u59cb\u5316\u9636\u6bb5\u6267\u884c\u66f4\u89c4\u8303<br \/>\n    public void init() {<br \/>\n        \/\/ \u6838\u5fc3&#xff1a;\u628aSpring\u6ce8\u5165\u7684Bean\u5b58\u5165\u9759\u6001\u53d8\u91cf<br \/>\n        WebSocketServer.userMapper &#061; this.tempUserMapper;<br \/>\n    }<\/p>\n<p>    \/\/ WebSocket\u6846\u67b6\u8c03\u7528\u7684\u6838\u5fc3\u65b9\u6cd5<br \/>\n    public void onMessage(String msg) {<br \/>\n        \/\/ \u4ece\u9759\u6001\u53d8\u91cf\u83b7\u53d6Bean&#xff0c;\u975eSpring\u5b9e\u4f8b\u4e5f\u80fd\u4f7f\u7528<br \/>\n        userMapper.insertMessage(msg);<br \/>\n    }<br \/>\n}<\/p>\n<h5>\u6b65\u9aa4 2&#xff1a;\u6267\u884c\u6d41\u7a0b\u62c6\u89e3<\/h5>\n<table>\n<tr>\n<p>\u6267\u884c\u9636\u6bb5<\/p>\n<p>\u884c\u4e3a\u4e3b\u4f53\u5177\u4f53\u52a8\u4f5c\u7ed3\u679c<\/tr>\n<tbody>\n<tr>\n<td>Spring \u542f\u52a8<\/td>\n<td>Spring \u5bb9\u5668<\/td>\n<td>\u626b\u63cf\u5230 &#064;Component&#xff0c;\u521b\u5efa WebSocketServer \u5de5\u5177\u4eba\u5b9e\u4f8b<\/td>\n<td>\u751f\u6210\u4e00\u4e2a Spring \u7ba1\u7406\u7684\u4e34\u65f6\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>\u4f9d\u8d56\u6ce8\u5165<\/td>\n<td>Spring \u5bb9\u5668<\/td>\n<td>\u7ed9\u5de5\u5177\u4eba\u5b9e\u4f8b\u6ce8\u5165\u771f\u5b9e\u7684 UserMapper \u5230 tempUserMapper<\/td>\n<td>\u5de5\u5177\u4eba\u5b9e\u4f8b\u62ff\u5230\u6709\u6548 Bean<\/td>\n<\/tr>\n<tr>\n<td>\u521d\u59cb\u5316\u9636\u6bb5<\/td>\n<td>Spring \u5bb9\u5668<\/td>\n<td>\u8c03\u7528 &#064;PostConstruct \u6807\u8bb0\u7684 init \u65b9\u6cd5<\/td>\n<td>\u5c06 Bean \u5b58\u5165\u9759\u6001\u53d8\u91cf&#xff08;\u516c\u5171\u4ed3\u5e93&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>WebSocket \u8fde\u63a5<\/td>\n<td>Tomcat \u5bb9\u5668<\/td>\n<td>new WebSocketServer () \u521b\u5efa\u4e1a\u52a1\u5b9e\u4f8b<\/td>\n<td>\n<p>\u4e1a\u52a1\u5b9e\u4f8b\u4ece\u9759\u6001\u53d8\u91cf\u83b7\u53d6 UserMapper<\/p>\n<\/p>\n<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u56db\u3001\u6838\u5fc3\u539f\u7406\u6df1\u5ea6\u89e3\u6790<\/h3>\n<h4>1. \u5de5\u5177\u4eba\u5b9e\u4f8b\u7684\u4f5c\u7528<\/h4>\n<p>Spring \u521b\u5efa\u7684\u300c\u5de5\u5177\u4eba\u5b9e\u4f8b\u300d\u672c\u8eab\u4e0d\u4f1a\u53c2\u4e0e\u4efb\u4f55\u4e1a\u52a1\u903b\u8f91&#xff0c;\u5176\u552f\u4e00\u4f5c\u7528\u662f&#xff1a;\u5229\u7528 Spring Bean \u7684\u8bbf\u95ee\u6743\u9650&#xff0c;\u62ff\u5230\u5bb9\u5668\u5185\u7684\u771f\u5b9e Bean&#xff0c;\u5e76\u4f20\u9012\u5230\u9759\u6001\u53d8\u91cf\u4e2d\u3002<\/p>\n<h4>2. \u9759\u6001\u53d8\u91cf\u7684\u5173\u952e\u4ef7\u503c<\/h4>\n<p>\u9759\u6001\u53d8\u91cf\u7a81\u7834\u4e86\u300c\u5b9e\u4f8b\u9694\u79bb\u300d\u7684\u9650\u5236&#xff1a;<\/p>\n<ul>\n<li>\u666e\u901a\u6210\u5458\u53d8\u91cf&#xff1a;\u6bcf\u4e2a\u5b9e\u4f8b\u6709\u72ec\u7acb\u526f\u672c&#xff08;\u6bd4\u5982\u5b9e\u4f8b A \u7684 userMapper \u548c\u5b9e\u4f8b B \u7684 userMapper \u662f\u4e24\u4e2a\u53d8\u91cf&#xff09;&#xff1b;<\/li>\n<li>\u9759\u6001\u53d8\u91cf&#xff1a;\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4e2a\u526f\u672c&#xff08;\u4e0d\u7ba1 new \u591a\u5c11\u4e2a WebSocketServer&#xff0c;\u90fd\u8bbf\u95ee\u540c\u4e00\u4e2a userMapper&#xff09;\u3002<\/li>\n<\/ul>\n<p>3. \u65b9\u6848\u672c\u8d28<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"292\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211103328-698c5af83ba12.png\" width=\"975\" \/><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u6559\u7a0b\u5f15\u8a00\u5728 Spring Boot \u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u4e60\u60ef\u4e86\u901a\u8fc7Autowired\/Resource\u7b49\u6ce8\u89e3\u8f7b\u677e\u6ce8\u5165\u4f9d\u8d56 Bean&#xff0c;\u4f46\u5728 WebSocket\u3001\u5b9a\u65f6\u4efb\u52a1\u3001\u7b2c\u4e09\u65b9\u6846\u67b6\u5b9e\u4f8b\u5316\u5bf9\u8c61\u7b49\u573a\u666f\u4e0b&#xff0c;\u4f1a\u9047\u5230\u4e00\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u975e Spring \u521b\u5efa\u7684\u5bf9\u8c61\u65e0\u6cd5\u76f4\u63a5\u6ce8\u5165 Spring Bean\u3002\u672c\u6559\u7a0b\u5c06\u62c6\u89e3\u8fd9\u4e00\u95ee\u9898\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u5e76\u8bb2\u89e3\u4e00\u79cd\u7ecf\u5178\u7684\u89e3\u51b3\u65b9\u6848 \u2014\u2014\u300c\u501f\u58f3\u6ce8\u5165  \u9759\u6001\u5171\u4eab\u300d&#xff0c;\u5e2e\u52a9\u4f60\u7406\u89e3\u5176\u6838\u5fc3\u539f\u7406\u5e76\u638c\u63e1\u5b9e<\/p>\n","protected":false},"author":2,"featured_media":75199,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,101,292],"topic":[],"class_list":["post-75200","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-spring","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/75200.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u6559\u7a0b\u5f15\u8a00\u5728 Spring Boot \u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u4e60\u60ef\u4e86\u901a\u8fc7Autowired\/Resource\u7b49\u6ce8\u89e3\u8f7b\u677e\u6ce8\u5165\u4f9d\u8d56 Bean&#xff0c;\u4f46\u5728 WebSocket\u3001\u5b9a\u65f6\u4efb\u52a1\u3001\u7b2c\u4e09\u65b9\u6846\u67b6\u5b9e\u4f8b\u5316\u5bf9\u8c61\u7b49\u573a\u666f\u4e0b&#xff0c;\u4f1a\u9047\u5230\u4e00\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u975e Spring \u521b\u5efa\u7684\u5bf9\u8c61\u65e0\u6cd5\u76f4\u63a5\u6ce8\u5165 Spring Bean\u3002\u672c\u6559\u7a0b\u5c06\u62c6\u89e3\u8fd9\u4e00\u95ee\u9898\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u5e76\u8bb2\u89e3\u4e00\u79cd\u7ecf\u5178\u7684\u89e3\u51b3\u65b9\u6848 \u2014\u2014\u300c\u501f\u58f3\u6ce8\u5165 \u9759\u6001\u5171\u4eab\u300d&#xff0c;\u5e2e\u52a9\u4f60\u7406\u89e3\u5176\u6838\u5fc3\u539f\u7406\u5e76\u638c\u63e1\u5b9e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/75200.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-11T10:33:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211103328-698c5af83ba12.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\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\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/75200.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/75200.html\",\"name\":\"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-11T10:33:29+00:00\",\"dateModified\":\"2026-02-11T10:33:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/75200.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/75200.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/75200.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/75200.html","og_locale":"zh_CN","og_type":"article","og_title":"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u6559\u7a0b\u5f15\u8a00\u5728 Spring Boot \u5f00\u53d1\u4e2d&#xff0c;\u6211\u4eec\u4e60\u60ef\u4e86\u901a\u8fc7Autowired\/Resource\u7b49\u6ce8\u89e3\u8f7b\u677e\u6ce8\u5165\u4f9d\u8d56 Bean&#xff0c;\u4f46\u5728 WebSocket\u3001\u5b9a\u65f6\u4efb\u52a1\u3001\u7b2c\u4e09\u65b9\u6846\u67b6\u5b9e\u4f8b\u5316\u5bf9\u8c61\u7b49\u573a\u666f\u4e0b&#xff0c;\u4f1a\u9047\u5230\u4e00\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u975e Spring \u521b\u5efa\u7684\u5bf9\u8c61\u65e0\u6cd5\u76f4\u63a5\u6ce8\u5165 Spring Bean\u3002\u672c\u6559\u7a0b\u5c06\u62c6\u89e3\u8fd9\u4e00\u95ee\u9898\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u5e76\u8bb2\u89e3\u4e00\u79cd\u7ecf\u5178\u7684\u89e3\u51b3\u65b9\u6848 \u2014\u2014\u300c\u501f\u58f3\u6ce8\u5165 \u9759\u6001\u5171\u4eab\u300d&#xff0c;\u5e2e\u52a9\u4f60\u7406\u89e3\u5176\u6838\u5fc3\u539f\u7406\u5e76\u638c\u63e1\u5b9e","og_url":"https:\/\/www.wsisp.com\/helps\/75200.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-11T10:33:29+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260211103328-698c5af83ba12.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/75200.html","url":"https:\/\/www.wsisp.com\/helps\/75200.html","name":"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-11T10:33:29+00:00","dateModified":"2026-02-11T10:33:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/75200.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/75200.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/75200.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u975e Spring \u7ba1\u7406\u5bf9\u8c61\u83b7\u53d6 Spring Bean"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/75200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=75200"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/75200\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/75199"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=75200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=75200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=75200"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=75200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}