{"id":756,"date":"2023-05-28T02:11:04","date_gmt":"2023-05-27T18:11:04","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=756"},"modified":"2023-05-28T02:11:04","modified_gmt":"2023-05-27T18:11:04","slug":"%e6%95%b4%e5%90%88spring%e9%83%bd%e5%96%9c%e6%ac%a2%e7%94%a8%e7%9a%84%e6%b3%a8%e8%a7%a3import%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e8%af%a6%e7%bb%86%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/%e6%95%b4%e5%90%88spring%e9%83%bd%e5%96%9c%e6%ac%a2%e7%94%a8%e7%9a%84%e6%b3%a8%e8%a7%a3import%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e8%af%a6%e7%bb%86%e4%bb%8b%e7%bb%8d\/","title":{"rendered":"\u6574\u5408Spring\u90fd\u559c\u6b22\u7528\u7684\u6ce8\u89e3@Import\u7684\u4f7f\u7528\u548c\u8be6\u7ec6\u4ecb\u7ecd"},"content":{"rendered":"<div class='wxsyncmain'>\n<section><mp-common-profile class=\"js_uneditable custom_select_card mp_profile_iframe\" data-pluginname=\"mpprofile\" data-weui-theme=\"light\" data-id=\"MzI3ODE5MzczNA==\" data-headimg=\"http:\/\/mmbiz.qpic.cn\/mmbiz_png\/OC2PjnBlMZjic6L6UHJXiaT0JCXiapkjUlh1wc5YRxBr1FvF4JB2kMibDia0m1vPHLtKr1BMxWm2QeGBRJhiaicbicw00w\/0?wx_fmt=png\" data-nickname=\"\u5218\u724c\" data-alias=\"\" data-signature=\"\u5bfb\u5e38\u7684\u74e6\u820d\u8bc4\u4e66\uff0c\u6697\u85cf\u7740\u6551\u4e16\u79d8\u8bc0\u3002\" data-from=\"0\" data-is_biz_ban=\"0\"><\/mp-common-profile><\/section>\n<section data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"line-height: 1.6;word-break: break-word;overflow-wrap: break-word;text-align: left;padding: 5px;font-size: 16px;color: rgb(53, 53, 53);word-spacing: 0.8px;letter-spacing: 0.8px;border-radius: 16px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;\">\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-weight: bold;color: black;font-size: 22px;margin-top: 20px;margin-right: 10px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 18px;color: rgb(34, 34, 34);display: inline-block;padding-left: 10px;border-left: 5px solid rgb(248, 57, 41);\">\u4ecb\u7ecd<\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin-top: 0.8em;margin-bottom: 0.8em;\">\u4eca\u5929\u4e3b\u8981\u4ecb\u7ecdSpring @Import\u6ce8\u89e3\uff0c\u5728Spring\u4e2d@Import\u4f7f\u7528\u5f97\u6bd4\u8f83\u9891\u7e41\uff0c\u5b83\u5f97\u4f5c\u7528\u662f\u5bfc\u5165bean\uff0c\u5177\u4f53\u7684\u5bfc\u5165\u65b9\u5f0f\u6709\u591a\u79cd\uff0c\u7279\u522b\u5728SpringBoot\u9879\u76ee\u4e2d\uff0c\u5f88\u591a\u5730\u65b9\u90fd\u4f7f\u7528\u5230\u4e86@Import\u6ce8\u89e3\uff0c\u7279\u522b\u5bf9\u4e8e\u4e00\u4e9b\u548cSpringBoot\u6574\u5408\u7684\u7ec4\u4ef6\uff0c\u5176\u5b9e\u73b0\u90fd\u5927\u91cf\u4f7f\u7528\u4e86@Import\uff0c\u4f8b\u5982\u4f7f\u7528Feign\u96c6\u6210SpringBoot\u65f6\u4f1a\u52a0\u4e0a\u6ce8\u89e3@EnableFeignClients\uff0c\u4f7f\u7528Dubbo\u65f6\u4f1a\u4f7f\u7528@EnableDubbo\u7b49\uff0c\u8fd9\u4e9b\u6ce8\u89e3\u91cc\u9762\u90fd\u4f7f\u7528\u4e86@Import\u6ce8\u89e3\u6765\u6ce8\u518c\u4e00\u4e9bbean\u3002<\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-weight: bold;color: black;font-size: 22px;margin-top: 20px;margin-right: 10px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 18px;color: rgb(34, 34, 34);display: inline-block;padding-left: 10px;border-left: 5px solid rgb(248, 57, 41);\">@Import\u5bfc\u5165bean\u7684\u4e09\u79cd\u65b9\u5f0f<\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin-top: 0.8em;margin-bottom: 0.8em;\">@Import\u5bfc\u5165bean\u6709\u4e09\u79cd\u65b9\u5f0f\uff0c\u5206\u522b\u662f\u5bfc\u5165<code style=\"font-size: 14px;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(255, 93, 108);\">\u666e\u901a\u7c7b<\/code>\uff0c\u5b9e\u73b0<code style=\"font-size: 14px;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(255, 93, 108);\">ImportSelector<\/code>\u63a5\u53e3\u7684\u7c7b\uff0c\u5b9e\u73b0<code style=\"font-size: 14px;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(255, 93, 108);\">ImportBeanDefinitionRegistrar<\/code>\u63a5\u53e3\u7684\u7c7b\u3002<\/p>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 16px;color: #222;\">\u666e\u901a\u7c7b<\/span><span style=\"display: none;\"><\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin-top: 0.8em;margin-bottom: 0.8em;\">\u5728\u5f00\u653e\u8fc7\u7a0b\u4e2d\uff0c\u5c3d\u91cf\u4fdd\u6301\u7c7b\u4e0d\u8981\u592a\u8fc7\u4e8e\u5e9e\u5927\uff0c\u7c7b\u8fc7\u4e8e\u5e9e\u5927\u7684\u8bdd\u4f1a\u53d8\u5f97\u81c3\u80bf\u590d\u6742\uff0c\u4e0d\u597d\u7ef4\u62a4\uff0c\u4e00\u4e2a\u914d\u7f6e\u7c7b\u4e2d\u9700\u8981\u914d\u7f6e\u5f88\u591abean\uff0c\u4e14\u903b\u8f91\u5b9e\u73b0\u4e5f\u6bd4\u8f83\u590d\u6742\uff0c\u4ee3\u7801\u91cf\u5927\uff0c\u5982\u679c\u5168\u90e8\u90fd\u653e\u5728\u540c\u4e00\u4e2a\u914d\u7f6e\u7c7b\u4e2d\uff0c\u8fd9\u663e\u7136\u4e0d\u592a\u7406\u667a\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5c06\u6bcf\u4e2abean\u5355\u72ec\u62ff\u51fa\u6765\u653e\u5230\u4e00\u4e2a\u7c7b\u91cc\u9762\uff0c\u7136\u540e\u4f7f\u7528@Import\u6ce8\u89e3\u5bfc\u5165\uff0c\u5982\u4e0b\u4ee3\u7801\u6240\u793a\u3002<\/p>\n<ul data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: rgb(248, 57, 41);\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(53, 53, 53);\">\u5b9a\u4e49\u4e00\u4e2abean<\/section>\n<\/li>\n<\/ul>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block;background: url(&quot;https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015905269.jpeg&quot;) 10px 10px \/ 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;\"><\/span><code style=\"overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;\"><span style=\"line-height: 26px;\"><span style=\"color: #c678dd;line-height: 26px;\">private<\/span>&nbsp;<span style=\"color: #c678dd;line-height: 26px;\">void<\/span>&nbsp;<span style=\"color: #61aeee;line-height: 26px;\">loadBeanDefinitionsFromRegistrars<\/span><span style=\"line-height: 26px;\">(Map&lt;ImportBeanDefinitionRegistrar,&nbsp;AnnotationMetadata&gt;&nbsp;registrars)<\/span>&nbsp;<\/span>{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;registrars.forEach((registrar,&nbsp;metadata)&nbsp;-&gt;<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;registrar.registerBeanDefinitions(metadata,&nbsp;<span style=\"color: #c678dd;line-height: 26px;\">this<\/span>.registry,&nbsp;<span style=\"color: #c678dd;line-height: 26px;\">this<\/span>.importBeanNameGenerator));<br  \/>&nbsp;}<br  \/><\/code><\/pre>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-width: initial;border-style: none;border-color: initial;font-size: 0.9em;overflow: auto;margin-bottom: 20px;margin-top: 20px;padding-top: 15px;padding-right: 10px;padding-bottom: 15px;line-height: 1.75;border-radius: 13px;color: rgb(53, 53, 53);background: rgb(245, 245, 245);\"><p><span style=\"display: block;font-size: 2em;color: rgb(248, 57, 41);font-family: Arial, serif;line-height: 1em;font-weight: 700;\">\u201c<\/span><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;font-size: 16px;margin-right: 10px;margin-left: 10px;\">\u4ece\u4e0a\u9762\u7684\u6e90\u7801\u89e3\u6790\u4e2d\uff0c\u6211\u4eec\u770b\u51fa\u901a\u8fc7@Import\u76f4\u63a5\u5bfc\u5165\u666e\u901a\u7684java\u7c7b\u548c\u5bfc\u5165\u5b9e\u73b0\u4e86ImportSelector\u63a5\u53e3\u7684\u7c7b\u662f\u76f4\u63a5\u6ce8\u518c\u8fdbBeanFactory\uff0c\u8fd9\u4e24\u8005\u672c\u8d28\u662f\u4e00\u6837\u7684\uff0c\u800c\u901a\u8fc7\u5b9e\u73b0ImportBeanDefinitionRegistrar\u63a5\u53e3\u65b9\u5f0f\u7684\u7c7b\u5219\u9700\u8981\u53bb\u5b9e\u73b0\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u6ce8\u518cbean\u5143\u4fe1\u606f\u7684\u903b\u8f91\u3002<\/p>\n<p><span style=\"float: right;display: block;font-size: 2em;color: rgb(248, 57, 41);font-family: Arial, serif;line-height: 1em;font-weight: 700;\">\u201d<\/span><\/p><\/blockquote>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-weight: bold;color: black;font-size: 22px;margin-top: 20px;margin-right: 10px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 18px;color: rgb(34, 34, 34);display: inline-block;padding-left: 10px;border-left: 5px solid rgb(248, 57, 41);\">\u603b\u7ed3<\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;line-height: 1.75;margin-top: 0.8em;margin-bottom: 0.8em;\">\u4e0a\u9762\u6211\u4eec\u4ecb\u7ecd\u4e86@Import\u7684\u4e00\u4e9b\u573a\u666f\uff0c@Import\u7528\u5f97\u6700\u591a\u8fd8\u662f\u4e00\u4e9b\u548cSpring\u7ed3\u5408\u7684\u4e2d\u95f4\u4ef6\u91cc\u9762\uff0c\u4e5f\u4ecb\u7ecd\u4e86\u5b83\u7684\u51e0\u79cd\u4f7f\u7528\u65b9\u5f0f\uff0c\u8fd8\u5bf9\u5b83\u7684\u6e90\u7801\u8fdb\u884c\u89e3\u6790\uff0c\u5f53\u7136\uff0c\u53ea\u662f\u4ece\u5b83\u6700\u4e3b\u8981\u7684\u903b\u8f91\u53bb\u5206\u6790\uff0c\u6df1\u5165\u7684\u903b\u8f91\u5c31\u6ca1\u53bb\u4e00\u4e00\u8be6\u89e3\uff0c\u638c\u63e1@Import\u6709\u52a9\u4e8e\u6211\u4eec\u5728\u4f7f\u7528\u4e00\u4e9b\u5176\u4ed6\u6846\u67b6\u7684\u65f6\u5019\u80fd\u591f\u4e86\u89e3\u6846\u67b6\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u7136\u540e\u66f4\u597d\u7684\u53bb\u4f7f\u7528\u6846\u67b6\uff01<\/p>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-width: initial;border-style: none;border-color: initial;font-size: 0.9em;overflow: auto;margin-bottom: 20px;margin-top: 20px;padding-top: 15px;padding-right: 10px;padding-bottom: 15px;line-height: 1.75;border-radius: 13px;color: rgb(53, 53, 53);background: rgb(245, 245, 245);\"><p><span style=\"display: block;font-size: 2em;color: rgb(248, 57, 41);font-family: Arial, serif;line-height: 1em;font-weight: 700;\">\u201c<\/span><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;line-height: 26px;font-size: 16px;margin-right: 10px;margin-left: 10px;\">\u4eca\u5929\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\uff0c\u611f\u8c22\u4f60\u7684\u89c2\u770b\uff0c\u4e0b\u671f\u89c1\u3002<\/p>\n<p><span style=\"float: right;display: block;font-size: 2em;color: rgb(248, 57, 41);font-family: Arial, serif;line-height: 1em;font-weight: 700;\">\u201d<\/span><\/p><\/blockquote>\n<\/section>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u5218\u724c              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u4ecb\u7ecd \u4eca\u5929\u4e3b\u8981\u4ecb\u7ecdSpring @Import\u6ce8\u89e3\uff0c\u5728Spring\u4e2d@Import\u4f7f\u7528\u5f97\u6bd4\u8f83\u9891\u7e41\uff0c\u5b83\u5f97\u4f5c\u7528\u662f\u5bfc\u5165bean\uff0c\u5177\u4f53\u7684\u5bfc &#8230;<\/p>\n","protected":false},"author":2,"featured_media":754,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-756","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015901207-150x150.jpeg","content_first_image":null,"post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015901207-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015901207-1024x435.jpeg","post_frist_image":null,"post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015901207-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015901207-1024x435.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015901207.jpeg","post_all_images":[],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2023-05-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":364,"next_post_id":1005,"next_post_title":"\u6570\u636e\u5e93\u94fe\u63a5\u6c60\u7ec8\u4e8e\u641e\u5bf9\u4e86\uff0c\u8fd9\u6b21\u76f4\u63a5\u4ece100ms\u4f18\u5316\u52303ms\uff01","previous_post_id":917,"previous_post_title":"Spring-15 Spring Certified Professional \u8bd5\u9898\u6574\u7406 \u2460","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=756"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/756\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/754"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}