{"id":2226,"date":"2024-11-10T13:04:21","date_gmt":"2024-11-10T05:04:21","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2226\/"},"modified":"2024-11-10T13:04:21","modified_gmt":"2024-11-10T05:04:21","slug":"spring-boot-%e9%a1%b9%e7%9b%ae-mapper-%e6%8e%a5%e5%8f%a3%e6%9c%aa%e8%a2%ab%e6%89%ab%e6%8f%8f%e5%af%bc%e8%87%b4%e5%90%8e%e5%8f%b0%e6%8a%a5%e9%94%99%ef%bc%8c%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2226\/","title":{"rendered":"Spring Boot \u9879\u76ee Mapper \u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5bfc\u81f4\u540e\u53f0\u62a5\u9519\uff0c\u600e\u4e48\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173069463715524.jpg\" class=\"aligncenter\" title=\"Spring Boot \u9879\u76ee Mapper \u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5bfc\u81f4\u540e\u53f0\u62a5\u9519\uff0c\u600e\u4e48\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"Spring Boot \u9879\u76ee Mapper \u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5bfc\u81f4\u540e\u53f0\u62a5\u9519\uff0c\u600e\u4e48\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>xml\u6587\u4ef6\u6709\u6807\u7ea2\u62a5\u9519\uff0c\u4f46\u8fd0\u884c\u6b63\u5e38<\/strong><\/p>\n<p>\u5728\u672c\u5730\u8fd0\u884c\u65f6\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u540e\uff0c\u540e\u53f0\u62a5\u9519\u3002\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u5f88\u53ef\u80fd\u662f\u56e0\u4e3a\uff1a<\/p>\n<p><strong>\u539f\u56e0\uff1a<\/strong><\/p>\n<p>mapper\u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5230\u3002<\/p>\n<p><strong>\u89e3\u51b3\u529e\u6cd5\uff1a<\/strong><\/p>\n<p>spring\u624d\u4f1a\u626b\u63cf\u5305\u4e0b\u7684\u6240\u6709\u63a5\u53e3\u5230\u5bb9\u5668\u4e2d\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5728\u542f\u52a8\u7c7b\u6216\u914d\u7f6e\u7c7b\u4e0a\u6dfb\u52a0@MapperScan\u6ce8\u89e3\uff0c\u6307\u5b9amapper\u63a5\u53e3\u6240\u5728\u5305\u8def\u5f84\u3002<\/p>\n<p><strong>\u6b63\u786e\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>\/\/ \u542f\u52a8\u7c7b\u4e0a\u6dfb\u52a0\u6ce8\u89e3\n@MapperScan(\"com.xxx.xxx.mapper\")\npublic class XXXApplication {\n    \/\/ ...\n}\n\n\/\/ \u914d\u7f6e\u7c7b\u4e0a\u6dfb\u52a0\u6ce8\u89e3\n@Configuration\n@MapperScan(\"com.xxx.xxx.mapper\")\npublic class MybatisConfig {\n    \/\/ ...\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6dfb\u52a0\u8be5\u6ce8\u89e3\u540e\uff0cspring\u5c31\u53ef\u4ee5\u8bc6\u522bmapper\u63a5\u53e3\uff0c\u5728\u6ce8\u5165\u65f6\u5c31\u4e0d\u4f1a\u51fa\u73b0\u7a7a\u6307\u9488\u5f02\u5e38\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSpring Boot \u9879\u76ee Mapper \u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5bfc\u81f4\u540e\u53f0\u62a5\u9519\uff0c\u600e\u4e48\u89e3\u51b3\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>xml\u6587\u4ef6\u6709\u6807\u7ea2\u62a5\u9519\uff0c\u4f46\u8fd0\u884c\u6b63\u5e38 \u5728\u672c\u5730\u8fd0\u884c\u65f6\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u540e\uff0c\u540e\u53f0\u62a5\u9519\u3002\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u5f88\u53ef\u80fd\u662f\u56e0\u4e3a\uff1a \u539f\u56e0\uff1a mapper\u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5230\u3002 \u89e3\u51b3\u529e\u6cd5\uff1a spring\u624d\u4f1a\u626b\u63cf\u5305\u4e0b\u7684\u6240\u6709\u63a5\u53e3\u5230\u5bb9\u5668\u4e2d\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5728\u542f\u52a8\u7c7b\u6216\u914d\u7f6e\u7c7b\u4e0a\u6dfb\u52a0@MapperScan\u6ce8\u89e3\uff0c\u6307\u5b9amapper\u63a5\u53e3\u6240\u5728\u5305\u8def\u5f84\u3002 \u6b63\u786e\u793a\u4f8b\uff1a \/\/ \u542f\u52a8\u7c7b\u4e0a\u6dfb\u52a0\u6ce8\u89e3 @MapperScan(&#8220;com.xxx.xxx.mapper&#8221;) public class XXXApplication { \/\/ &#8230; } \/\/ \u914d\u7f6e\u7c7b\u4e0a\u6dfb\u52a0\u6ce8\u89e3 @Configuration @MapperScan(&#8220;com.xxx.xxx.mapper&#8221;) public class MybatisConfig { \/\/ &#8230; } \u767b\u5f55\u540e\u590d\u5236 \u6dfb\u52a0\u8be5\u6ce8\u89e3\u540e\uff0cspring\u5c31\u53ef\u4ee5\u8bc6\u522bmapper\u63a5\u53e3\uff0c\u5728\u6ce8\u5165\u65f6\u5c31\u4e0d\u4f1a\u51fa\u73b0\u7a7a\u6307\u9488\u5f02\u5e38\u4e86\u3002 \u4ee5\u4e0a\u5c31\u662fSpring Boot \u9879\u76ee Mapper \u63a5\u53e3\u672a\u88ab\u626b\u63cf\u5bfc\u81f4\u540e\u53f0\u62a5\u9519\uff0c\u600e\u4e48\u89e3\u51b3\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2226","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2226","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=2226"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2226\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}