{"id":34414,"date":"2024-11-26T12:30:39","date_gmt":"2024-11-26T04:30:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/34414\/"},"modified":"2024-11-26T12:30:39","modified_gmt":"2024-11-26T04:30:39","slug":"%e4%bd%bf%e7%94%a8-amq-%e6%97%b6%e5%88%a0%e9%99%a4%e6%93%8d%e4%bd%9c%e5%a4%b1%e8%b4%a5%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3-spring-ioc-%e5%ae%b9%e5%99%a8%e4%b8%ad-bean-%e5%90%8d%e7%a7%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/34414\/","title":{"rendered":"\u4f7f\u7528 AMQ \u65f6\u5220\u9664\u64cd\u4f5c\u5931\u8d25\uff1a\u5982\u4f55\u89e3\u51b3 Spring IOC \u5bb9\u5668\u4e2d Bean \u540d\u79f0\u51b2\u7a81\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173051569322964.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 AMQ \u65f6\u5220\u9664\u64cd\u4f5c\u5931\u8d25\uff1a\u5982\u4f55\u89e3\u51b3 Spring IOC \u5bb9\u5668\u4e2d Bean \u540d\u79f0\u51b2\u7a81\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528 AMQ \u65f6\u5220\u9664\u64cd\u4f5c\u5931\u8d25\uff1a\u5982\u4f55\u89e3\u51b3 Spring IOC \u5bb9\u5668\u4e2d Bean \u540d\u79f0\u51b2\u7a81\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5220\u9664\u64cd\u4f5c\u65f6\u4f7f\u7528 amq \u9047\u5230\u7684\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 amq \u6d88\u606f\u4e2d\u95f4\u4ef6\u8fdb\u884c\u6570\u636e\u5bfc\u5165\u548c\u6d88\u606f\u53d1\u9001\u65f6\uff0c\u9047\u5230\u4e86\u5220\u9664\u64cd\u4f5c\u65e0\u6cd5\u6b63\u5e38\u8fdb\u884c\u7684\u95ee\u9898\uff0c\u9519\u8bef\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<pre>[ERROR] org.springframework.beans.factory.BeanDefinitionStoreException: Bean named 'mongoTemplate' already exists in the same scope 'singleton',. If bean name collision is not desired, then consider revisiting the bean definition registration process in your configuration.<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u539f\u56e0\u5206\u6790<\/strong><\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u4e0e amq \u65e0\u5173\uff0c\u800c\u662f\u7531\u4e8e\u5728 spring ioc \u5bb9\u5668\u4e2d\u6ce8\u518c\u4e86\u4e24\u4e2a\u540c\u540d\u7684 bean\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u68c0\u67e5\u5e76\u786e\u4fdd\u5728 spring \u914d\u7f6e\u4e2d\u6ca1\u6709\u91cd\u590d\u6ce8\u518c bean \u540d\u79f0\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6539  \u6a21\u677f bean \u7684\u540d\u79f0\uff0c\u6216\u786e\u4fdd\u4e0d\u91cd\u590d\u5b9a\u4e49\u76f8\u540c\u7684 bean\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 AMQ \u65f6\u5220\u9664\u64cd\u4f5c\u5931\u8d25\uff1a\u5982\u4f55\u89e3\u51b3 Spring IOC \u5bb9\u5668\u4e2d Bean \u540d\u79f0\u51b2\u7a81\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5220\u9664\u64cd\u4f5c\u65f6\u4f7f\u7528 amq \u9047\u5230\u7684\u95ee\u9898 \u5728\u4f7f\u7528 amq \u6d88\u606f\u4e2d\u95f4\u4ef6\u8fdb\u884c\u6570\u636e\u5bfc\u5165\u548c\u6d88\u606f\u53d1\u9001\u65f6\uff0c\u9047\u5230\u4e86\u5220\u9664\u64cd\u4f5c\u65e0\u6cd5\u6b63\u5e38\u8fdb\u884c\u7684\u95ee\u9898\uff0c\u9519\u8bef\u4fe1\u606f\u5982\u4e0b\uff1a [ERROR] org.springframework.beans.factory.BeanDefinitionStoreException: Bean named &#8216;mongoTemplate&#8217; already exists in the same scope &#8216;singleton&#8217;,. If bean name collision is not desired, then consider revisiting the bean definition registration process in your configuration. \u767b\u5f55\u540e\u590d\u5236 \u539f\u56e0\u5206\u6790 \u8fd9\u4e2a\u95ee\u9898\u4e0e amq \u65e0\u5173\uff0c\u800c\u662f\u7531\u4e8e\u5728 spring ioc \u5bb9\u5668\u4e2d\u6ce8\u518c\u4e86\u4e24\u4e2a\u540c\u540d\u7684 bean\u3002 \u89e3\u51b3\u65b9\u6848 \u68c0\u67e5\u5e76\u786e\u4fdd\u5728 spring \u914d\u7f6e\u4e2d\u6ca1\u6709\u91cd\u590d\u6ce8\u518c bean \u540d\u79f0\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6539 \u6a21\u677f bean \u7684\u540d\u79f0\uff0c\u6216\u786e\u4fdd\u4e0d\u91cd\u590d\u5b9a\u4e49\u76f8\u540c\u7684 bean\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-34414","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=34414"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34414\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=34414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=34414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=34414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}