{"id":10007009,"date":"2022-12-26T09:25:07","date_gmt":"2022-12-26T01:25:07","guid":{"rendered":"https:\/\/ityet.com\/?p=10007009"},"modified":"2022-12-26T09:25:07","modified_gmt":"2022-12-26T01:25:07","slug":"%e7%ac%91%e6%ad%bb%ef%bc%8c%e9%9d%a2%e8%af%95%e5%ae%98%e5%8f%88%e9%97%ae%e6%88%91springboot%e8%87%aa%e5%8a%a8%e9%85%8d%e7%bd%ae%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10007009","title":{"rendered":"\u7b11\u6b7b\uff0c\u9762\u8bd5\u5b98\u53c8\u95ee\u6211SpringBoot\u81ea\u52a8\u914d\u7f6e\u539f\u7406"},"content":{"rendered":"<p>\u9762\u8bd5\u5b98\uff1a\u597d\u4e45\u6ca1\u89c1\uff0c\u751a\u662f\u60f3\u5ff5\u3002\u4eca\u5929\u6765\u804a\u804aSpringBoot\u7684\u81ea\u52a8\u914d\u7f6e\u5427\uff1f<\/p>\n<p>\u5019\u9009\u8005\uff1a\u55ef\uff0cSpringBoot\u7684\u81ea\u52a8\u914d\u7f6e\u6211\u89c9\u5f97\u662fSpringBoot\u5f88\u91cd\u8981\u7684\u201c\u7279\u6027\u201d\u4e86\u3002\u4f17\u6240\u5468\u77e5\uff0cSpringBoot\u6709\u7740\u201c\u7ea6\u5b9a\u5927\u4e8e\u914d\u7f6e\u201d\u7684\u7406\u5ff5\uff0c\u8fd9\u4e00\u7406\u5ff5\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u53ef\u4ee5\u7528\u201cSpringBoot\u81ea\u52a8\u914d\u7f6e\u201d\u6765\u89e3\u91ca\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043150465\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5019\u9009\u8005\uff1aSpringBoot\u81ea\u52a8\u914d\u7f6e\u7684\u539f\u7406\u7406\u89e3\u8d77\u6765\u633a\u7b80\u5355\u7684\uff0c\u6211\u4eec\u5728\u4f7f\u7528SpringBoot\u7684\u65f6\u5019\uff0c\u80af\u5b9a\u4f1a\u4f9d\u8d56\u4e8eautoconfigure\u8fd9\u4e48\u4e00\u4e2a\u5305<\/p>\n<p>\u5019\u9009\u8005\uff1aautoconfigure\u8fd9\u4e2a\u5305\u91cc\u4f1a\u6709\u4e00\u4e2aspring.factories\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u5b9a\u4e49\u4e86100+\u4e2a\u5165\u53e3\u7684\u914d\u7f6e\u7c7b\u3002\u6bd4\u5982\u6211\u4eec\u7ecf\u5e38\u4f7f\u7528\u7684redis\u3001kafka\u7b49\u7b49\u8fd9\u6837\u5e38\u89c1\u7684\u4e2d\u95f4\u4ef6\u90fd<strong>\u9884\u7f6e<\/strong>\u4e86\u914d\u7f6e\u7c7b<\/p>\n<p>\u5019\u9009\u8005\uff1a\u5f53\u6211\u4eec\u5728\u542f\u52a8SpringBoot\u9879\u76ee\u7684\u65f6\u5019\uff0c\u5185\u90e8\u5c31\u4f1a\u52a0\u8f7d\u8fd9\u4e2aspring.factories\u6587\u4ef6\uff0c\u8fdb\u800c\u53bb\u52a0\u8f7d\u201c\u6709\u9700\u8981\u201d\u7684\u914d\u7f6e\u7c7b\u3002\u90a3\u6211\u4eec\u5728\u4f7f\u7528\u76f8\u5173\u7ec4\u4ef6\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u975e\u5e38\u7684\u65b9\u4fbf\uff08\u56e0\u4e3a\u914d\u7f6e\u7c7b\u5df2\u7ecf\u521d\u59cb\u5316\u4e86\u4e00\u5927\u90e8\u5206\u914d\u7f6e\u4fe1\u606f\uff09\u3002<\/p>\n<p>\u5019\u9009\u8005\uff1a\u4e00\u822c\u6211\u4eec\u53ea\u8981\u5728application\u914d\u7f6e\u6587\u4ef6\u5199\u4e0a\u5bf9\u5e94\u7684\u914d\u7f6e\uff0c\u5c31\u80fd\u901a\u8fc7\u5404\u79cdtemplate\u7c7b\u76f4\u63a5\u64cd\u4f5c\u5bf9\u5e94\u7684\u7ec4\u4ef6\u5566\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043150466\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u9762\u8bd5\u5b98\uff1a\u90a3\u662f\u6240\u6709\u7684\u914d\u7f6e\u7c7b\u90fd\u4f1a\u52a0\u8f7d\u5417\uff1f\u8fd9\u4e2a\u201c\u6709\u9700\u8981\u201d\u7684\u914d\u7f6e\u7c7b\u4f60\u662f\u600e\u4e48\u7406\u89e3\u7684\uff1f<\/p>\n<p>\u5019\u9009\u8005\uff1a\u4e0d\u662f\u6240\u6709\u7684\u914d\u7f6e\u7c7b\u90fd\u4f1a\u52a0\u8f7d\u7684\uff0c\u5047\u8bbe\u6211\u4eec\u6ca1\u6709\u5f15\u5165redis-starter\u7684\u5305\uff0c\u90a3Redis\u7684\u914d\u7f6e\u7c7b\u5c31\u4e0d\u4f1a\u88ab\u52a0\u8f7d\u3002\u5177\u4f53Spring\u5728\u5b9e\u73b0\u7684\u65f6\u5019\u5c31\u662f\u4f7f\u7528 <strong>@ConditionalXXX<\/strong>\u8fdb\u884c\u5224\u65ad\u7684\u3002\u6bd4\u5982Redis\u7684\u914d\u7f6e\u7c7b\u5c31\u4f1a\u6709@ConditionalOnClass({RedisOperations.class})\u7684\u914d\u7f6e\uff0c\u8bf4\u660e\u5f53\u524d\u73af\u5883\u4e0b\u5982\u679c\u6709RedisOperations.class\u8fd9\u4e2a\u5b57\u8282\u7801\uff0c\u624d\u4f1a\u53bb\u52a0\u8f7dRedis\u7684\u914d\u7f6e\u7c7b<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043150467\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u9762\u8bd5\u5b98\uff1a\u54e6\uff0c\u8fd9\u6837\u554a\uff0c\u90a3\u4e86\u89e3\u4e86\u3002\u90a3\u4f60\u77e5\u4e0d\u77e5\u9053Redis\u7684\u914d\u7f6e\u7c7b\u5176\u5b9e\u4f1a\u6709\u521d\u59cb\u5316RedisTemplate\u5bf9\u8c61\u7684\u64cd\u4f5c\uff0c\u90a3\u5047\u8bbe\u6211\u4eec\u6ca1\u6709\u5f15\u5165redis-starter\u5305\uff0c\u90a3\u4ed6\u662f\u600e\u4e48\u901a\u8fc7\u7f16\u8bd1\u7684\uff1f\uff08\u5f53\u7136\u4e86\uff0c\u5176\u4ed6\u7684\u914d\u7f6e\u7c7b\u4e5f\u662f\u6709\u53ef\u80fd\u6709\u4e00\u6837\u7684\u72b6\u51b5\uff09<\/p>\n<p>\u5019\u9009\u8005\uff1a\u55ef\uff0c\u8fd9\u4e2a\u6211\u770b\u6e90\u7801\u7684\u65f6\u5019\u6211\u4e5f\u53d1\u73b0\u4e86\u3002\u5176\u5b9e\u5c31\u662f\u5728autoconfigure\u5305\u91cc<strong>\u4f1a\u5b9a\u4e49\u5230\u76f8\u5173\u7684\u4f9d\u8d56<\/strong>\uff0c\u4f46\u53ea\u662f\u6807\u8bb0\u4e3aoptional\u5e76\u4e14\u53ea\u5728\u7f16\u8bd1\u73af\u5883\u6709\u6548\u3002\u90a3\u8fd9\u6837\u662f\u80fd\u901a\u8fc7\u7f16\u8bd1\u7684\uff0c<strong>\u53ea\u662f\u4e0d\u4f1a\u5c06\u5176\u4f9d\u8d56\u4f20\u5165\u5230\u6211\u4eec\u7684\u5e94\u7528\u5de5\u7a0b\u91cc<\/strong>\u3002<\/p>\n<p>\u5019\u9009\u8005\uff1a\u8fd9\u5757\u8fd8\u662f\u82b1\u4e86\u6211\u5f88\u591a\u65f6\u95f4\u7684\uff0c\u6211\u6700\u540e\u5728GitHub \u7684SpringBoot\u6e90\u7801\u91cc\u627e\u5230\u7684\u3002<\/p>\n<p>\u9762\u8bd5\u5b98\uff1a\u55ef\u554a\uff0c\u6709\u70b9\u4e1c\u897f\u7684\u54df\u3002\u65e2\u7136\u90fd\u804a\u5230\u8fd9\u5757\u4e86\uff0c\u8981\u4e0d\u987a\u4fbf\u804a\u804a\u4f60\u5bf9SpringBoot starter\u7684\u7406\u89e3\uff1f<\/p>\n<p>\u5019\u9009\u8005\uff1a\u55ef\uff0cstarter\u8fd9\u4e1c\u897f\u5c31\u662f\u4e3a\u4e86<strong>\u65b9\u4fbf\u8c03\u7528\u65b9\u53bb\u4f7f\u7528\u76f8\u5173\u7684\u7ec4\u4ef6<\/strong>\u7684\u561b\uff0cSpring\u6846\u67b6\u4e5f\u7ed9\u6211\u4eec\u5b9e\u73b0\u4e86\u5f88\u591a\u597d\u7528\u7684starter\u3002<\/p>\n<p>\u5019\u9009\u8005\uff1a\u6bd4\u5982\u4ee5\u524d\u6211\u4eec\u8981\u7528Mybatis\u6846\u67b6\uff0c\u53ef\u80fd\u4f1a\u5f15\u5165\u5404\u79cd\u7684\u5305\u624d\u80fd\u4f7f\u7528\u3002\u800cstarter\u5c31\u662f\u505a\u4e86\u4e00\u5c42\u5c01\u88c5\uff0c\u628a\u76f8\u5173\u8981\u7528\u5230\u7684jar\u90fd\u7ed9\u5305\u8d77\u6765\u4e86\uff0c\u5e76\u4e14\u4e5f\u5199\u597d\u4e86\u5bf9\u5e94\u7684\u7248\u672c\u3002\u8fd9\u6211\u4eec\u4f7f\u7528\u7684\u65f6\u5019\u5c31\u4e0d\u9700\u8981\u5f15\u5165\u4e00\u5806jar\u5305\u4e14\u7ba1\u7406\u7248\u672c\u7c7b\u4f3c\u7684\u95ee\u9898\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043150468\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5019\u9009\u8005\uff1a\u73b0\u5728\u5f88\u591a\u5f00\u6e90\u7684\u7ec4\u4ef6\u90fd\u4f1a\u63d0\u4f9b\u5bf9\u5e94\u7684springboot-starter\u5305\u7ed9\u6211\u4eec\u53bb\u7528\uff0c\u8981\u505a\u4e00\u4e2astarter\u5305\u5e76\u4e0d\u96be\u3002\u53c2\u7167Spring\u5185\u7f6e\u7684\u5b9e\u73b0\u5c31\u597d\u4e86\uff1a1\u3001\u5728\u5de5\u7a0b\u91cc\u5f15\u5165 starter \u6253\u5305\u76f8\u5173\u7684\u4f9d\u8d56\u30022\u3001\u5728\u6211\u4eec\u5de5\u7a0b\u5185\u5efaspring.factories\u6587\u4ef6\uff0c\u7f16\u5199\u6211\u4eec\u914d\u7f6e\u7c7b\u7684\u5168\u9650\u7c7b\u540d\u3002<\/p>\n<p>\u9762\u8bd5\u5b98\uff1a\u55ef\uff0c\u5927\u81f4\u90fd\u4e86\u89e3\u4e86\uff0c\u53ef\u4ee5\u7684\u3002\u6700\u540e\u804a\u4e0b\u4f60\u662f\u600e\u4e48\u770b\u8fd9\u5757\u6e90\u7801\u7684\uff1f<\/p>\n<p>\u5019\u9009\u8005\uff1a\u6e90\u7801\u5177\u4f53\u5927\u6982\u5c31\u4e0d\u8bb0\u5f97\u4e86\uff0c\u601d\u8def\u5012\u662f\u8fd8\u6709\u7684\u3002\u6211\u5148\u4ece\u542f\u52a8\u7c7b\u5f00\u59cb\uff0c\u4f1a\u6709\u4e2a@SpringBootApplication\uff0c\u540e\u9762\u4f1a\u5b9a\u4f4d\u5230\u4e00\u4e2a\u81ea\u52a8\u914d\u7f6e\u7684\u6ce8\u89e3@EnableAutoConfiguration\uff0c\u90a3\u6700\u540e\u5c31\u80fd\u770b\u5230\u6ce8\u89e3\u5185\u90e8\u4f1a\u53bbMETA-INF\/spring.factories\u52a0\u8f7d\u914d\u7f6e\u7c7b<\/p>\n<p>\u5019\u9009\u8005\uff1a\u8fd9\u5757\u6e90\u7801\u5e76\u4e0d\u96be\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u4e5f\u4e86\u89e3\u5230\u4e86\u539f\u6765maven\u6709option\u548cscope\u8fd9\u4fe9\u6807\u7b7e\uff0c\u4f46\u786e\u5b9e\u662fSpringBoot\u6bd4\u8f83\u91cd\u8981\u7684\u6982\u5ff5\u5427\u3002<\/p>\n<p>\u9762\u8bd5\u5b98\uff1a\u597d\u561e\uff0c\u4eca\u5929\u5230\u8fd9\u5c31\u7ed3\u675f\u4e86\u5427\u3002<\/p>\n<p><strong>\u9898\u5916<\/strong>\uff1a\u81ea\u52a8\u914d\u7f6e\u8fd9\u4e2a\u95ee\u9898\u786e\u5b9e\u88ab\u95ee\u5230\u8fc7\u51e0\u6b21\u3002\u8bf4\u5b9e\u5728\u7684\uff0c\u5bf9\u4e8eSpring\u7c7b\u3001\u6ce8\u89e3\u7684\u4fe1\u606f\u6211\u771f\u7684\u8bb0\u4e0d\u4f4f\u3002\u611f\u89c9\u80fd\u7b54\u51fa\u8fd9\u4e2a\u6d41\u7a0b\u601d\u8def\uff0c\u4e5f\u5c31\u591f\u7528\u4e86\uff08\u5982\u679c\u9762\u8bd5\u5b98\u786e\u5b9e\u662f\u8981\u7ec6\u7a76\u67d0\u4e2a\u7c7b\u540d\uff0c\u90a3\u8fd9\u79cd\u516c\u53f8\u4e0d\u53bb\u4e5f\u7f62\uff09<\/p>\n<p><strong>\u7ea6\u5b9a\u5927\u4e8e\u914d\u7f6e<\/strong>\uff1aSpringBoot\u7ed9\u6211\u4eec\u5185\u7f6e\u4e86\u5f88\u591a\u914d\u7f6e\u7c7b\uff0c\u8fd9\u4e9b\u914d\u7f6e\u7c7b\u4e5f\u521d\u59cb\u5316\u4e86\u5f88\u591a\u914d\u7f6e\uff08<strong>\u9ed8\u8ba4\u503c<\/strong>\uff09\u3002\u5f53\u6211\u4eec\u8981\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u8986\u76d6\u8fd9\u4e9b\u914d\u7f6e\u9879\u5c31\u5b8c\u4e8b\u4e86\u3002\u5373\u4fbf\u6211\u4eec\u4e0d\u5199\uff0c\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u90fd\u4e0d\u9700\u8981\u7531\u6211\u4eec\u663e\u793a\u914d\u7f6e\u51fa\u6765\uff0c\u4f46\u76f8\u5173\u7ec4\u4ef6\u5c31\u80fd\u6b63\u5e38\u8bbf\u95ee\u4e86\u3002<\/p>\n<h2>\u63a8\u8350\u9879\u76ee<\/h2>\n<p>\u5982\u679c\u60f3\u5b66Java\u9879\u76ee\u7684\uff0c\u6211\u8fd8\u662f<strong>\u5f3a\u70c8\u63a8\u8350<\/strong>\u6211\u7684\u5f00\u6e90\u9879\u76ee\u6d88\u606f\u63a8\u9001\u5e73\u53f0Austin\uff0c\u53ef\u4ee5\u7528\u4f5c<strong>\u6bd5\u4e1a\u8bbe\u8ba1<\/strong>\uff0c\u53ef\u4ee5\u7528\u4f5c<strong>\u6821\u62db<\/strong>\uff0c\u53ef\u4ee5\u770b\u770b<strong>\u751f\u4ea7\u73af\u5883\u662f\u600e\u4e48\u63a8\u9001\u6d88\u606f<\/strong>\u7684\u3002  <\/p>\n<p>Gitee\u4ed3\u5e93\u5730\u5740\uff1a<strong><a href=\"https:\/\/link.segmentfault.com\/?enc=3Y7R4XRkPkUyWgDXLc0J6Q%3D%3D.%2BiaYfg3IWgMPOM6TGUZ5fmeJxypB%2B5zKqF6HFN8Lrtu2INm0QRiUkw2fy4%2BwLDJm\" rel=\"nofollow\">https:\/\/gitee.com\/zhongfuchen&#8230;<\/a><\/strong><\/p>\n<p>GitHub\u4ed3\u5e93\u5730\u5740\uff1a<strong><a href=\"https:\/\/link.segmentfault.com\/?enc=z2LgcmXFZtprZuiuL%2FBG6Q%3D%3D.3HYL8jvY%2FyDqc%2BMrv5otruYivCiPNVXuIcctAtoSpDGkCJr%2FfFRqsu%2FExMWisXhF\" rel=\"nofollow\">https:\/\/github.com\/ZhongFuChe&#8230;<\/a><\/strong><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000043150463\">https:\/\/segmentfault.com\/a\/1190000043150463<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9762\u8bd5\u5b98\uff1a\u597d\u4e45\u6ca1\u89c1\uff0c\u751a\u662f\u60f3\u5ff5\u3002\u4eca\u5929\u6765\u804a\u804aSpringBoot\u7684\u81ea\u52a8\u914d\u7f6e\u5427\uff1f \u5019\u9009\u8005\uff1a\u55ef\uff0cSpringBoot\u7684\u81ea [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10007009","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10007009"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007009\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10007009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10007009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10007009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}