{"id":7153,"date":"2024-11-14T10:32:06","date_gmt":"2024-11-14T02:32:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7153\/"},"modified":"2024-11-14T10:32:06","modified_gmt":"2024-11-14T02:32:06","slug":"spring-boot-%e6%9f%a5%e8%af%a2%e4%b8%ba%e7%a9%ba%ef%bc%8c%e5%a6%82%e4%bd%95%e7%94%a8-mybatis-%e8%af%8a%e6%96%ad-%e5%92%8c-%e7%9a%84%e5%8c%ba%e5%88%ab%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7153\/","title":{"rendered":"Spring Boot \u67e5\u8be2\u4e3a\u7a7a\uff0c\u5982\u4f55\u7528 MyBatis \u8bca\u65ad # \u548c $ \u7684\u533a\u522b\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173053497462420.jpg\" class=\"aligncenter\" title=\"Spring Boot \u67e5\u8be2\u4e3a\u7a7a\uff0c\u5982\u4f55\u7528 MyBatis \u8bca\u65ad # \u548c $ \u7684\u533a\u522b\uff1f\u63d2\u56fe\" alt=\"Spring Boot \u67e5\u8be2\u4e3a\u7a7a\uff0c\u5982\u4f55\u7528 MyBatis \u8bca\u65ad # \u548c $ \u7684\u533a\u522b\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>Spring Boot SQL \u67e5\u8be2\u65e0\u7ed3\u679c\uff0c\u5982\u4f55\u8bca\u65ad\uff1f<\/strong><\/p>\n<p>\u5728 Spring Boot \u4e2d\uff0c\u4f60\u9047\u5230\u4e86\u67e5\u8be2\u4e3a\u7a7a\u7684\u95ee\u9898\u3002\u901a\u8fc7\u4e0e Navicat \u4e2d\u7684\u539f\u751f SQL \u67e5\u8be2\u5bf9\u6bd4\uff0c\u53d1\u73b0\u53ea\u6709\u5728 where \u5b50\u53e5\u4e2d\u4f20\u9012\u7a7a\u503c\u65f6\uff0c\u67e5\u8be2\u624d\u6210\u529f\u3002<\/p>\n<p>\u6839\u636e\u95ee\u9898\u7684\u63cf\u8ff0\uff0c\u6211\u4eec\u6765\u5206\u6790\u6f5c\u5728\u7684\u539f\u56e0\uff1a<\/p>\n<p><strong># \u548c $ \u7684<\/strong><\/p>\n<p>\u5728 MyBatis \u4e2d\uff0c#{} \u548c ${} \u7528\u4e8e\u8868\u793a\u67e5\u8be2\u53c2\u6570\u3002#{}\u7528\u4e8e\u8bbe\u7f6e\u76f4\u63a5\u503c\uff0c\u800c${}\u7528\u4e8e\u8bbe\u7f6e\u52a8\u6001\u503c\u3002<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u4f7f\u7528 #{} \u4f20\u9012\u7a7a\u503c\uff0c\u5219 SQL \u8bed\u53e5\u5c06\u65e0\u6cd5\u8bc6\u522b\u4f5c\u4e3a\u6761\u4ef6\uff0c\u56e0\u6b64\u5bfc\u81f4\u67e5\u8be2\u4e3a\u7a7a\u3002\u800c\u4f7f\u7528 ${} \u52a8\u6001\u4f20\u9012\u7a7a\u503c\u65f6\uff0cSQL \u8bed\u53e5\u53ef\u4ee5\u5c06\u6761\u4ef6\u66ff\u6362\u4e3a NULL\uff0c\u4ece\u800c\u8fd4\u56de\u9884\u671f\u7ed3\u679c\u3002<\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8bf7\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u786e\u4fdd where \u5b50\u53e5\u4e2d\u7684\u53d8\u91cf\u5df2\u6b63\u786e\u521d\u59cb\u5316\uff0c\u660e\u786e\u4f20\u9012\u975e\u7a7a\u503c\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u4f7f\u7528\u7a7a\u503c\u8fdb\u884c\u67e5\u8be2\uff0c\u8bf7\u4f7f\u7528 ${} \u8bed\u6cd5\u8bbe\u7f6e\u52a8\u6001\u503c\u3002<\/li>\n<\/ul>\n<p><strong>\u63a8\u8350\u5de5\u5177<\/strong><\/p>\n<p>\u82e5\u8981\u65b9\u4fbf\u5730\u8c03\u8bd5\u6b64\u7c7b\u95ee\u9898\uff0c\u5efa\u8bae\u5b89\u88c5 MyBatis Log \u63d2\u4ef6\u3002\u8be5\u63d2\u4ef6\u5c06\u5728\u63a7\u5236\u53f0\u4e2d\u6253\u5370\u8be6\u7ec6\u7684 SQL \u8bed\u53e5\u548c\u53c2\u6570\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u627e\u51fa\u95ee\u9898\u6240\u5728\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSpring Boot \u67e5\u8be2\u4e3a\u7a7a\uff0c\u5982\u4f55\u7528 MyBatis \u8bca\u65ad # \u548c $ \u7684\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot SQL \u67e5\u8be2\u65e0\u7ed3\u679c\uff0c\u5982\u4f55\u8bca\u65ad\uff1f \u5728 Spring Boot \u4e2d\uff0c\u4f60\u9047\u5230\u4e86\u67e5\u8be2\u4e3a\u7a7a\u7684\u95ee\u9898\u3002\u901a\u8fc7\u4e0e Navicat \u4e2d\u7684\u539f\u751f SQL \u67e5\u8be2\u5bf9\u6bd4\uff0c\u53d1\u73b0\u53ea\u6709\u5728 where \u5b50\u53e5\u4e2d\u4f20\u9012\u7a7a\u503c\u65f6\uff0c\u67e5\u8be2\u624d\u6210\u529f\u3002 \u6839\u636e\u95ee\u9898\u7684\u63cf\u8ff0\uff0c\u6211\u4eec\u6765\u5206\u6790\u6f5c\u5728\u7684\u539f\u56e0\uff1a # \u548c $ \u7684 \u5728 MyBatis \u4e2d\uff0c#{} \u548c ${} \u7528\u4e8e\u8868\u793a\u67e5\u8be2\u53c2\u6570\u3002#{}\u7528\u4e8e\u8bbe\u7f6e\u76f4\u63a5\u503c\uff0c\u800c${}\u7528\u4e8e\u8bbe\u7f6e\u52a8\u6001\u503c\u3002 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u4f7f\u7528 #{} \u4f20\u9012\u7a7a\u503c\uff0c\u5219 SQL \u8bed\u53e5\u5c06\u65e0\u6cd5\u8bc6\u522b\u4f5c\u4e3a\u6761\u4ef6\uff0c\u56e0\u6b64\u5bfc\u81f4\u67e5\u8be2\u4e3a\u7a7a\u3002\u800c\u4f7f\u7528 ${} \u52a8\u6001\u4f20\u9012\u7a7a\u503c\u65f6\uff0cSQL \u8bed\u53e5\u53ef\u4ee5\u5c06\u6761\u4ef6\u66ff\u6362\u4e3a NULL\uff0c\u4ece\u800c\u8fd4\u56de\u9884\u671f\u7ed3\u679c\u3002 \u5982\u4f55\u89e3\u51b3 \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8bf7\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u786e\u4fdd where \u5b50\u53e5\u4e2d\u7684\u53d8\u91cf\u5df2\u6b63\u786e\u521d\u59cb\u5316\uff0c\u660e\u786e\u4f20\u9012\u975e\u7a7a\u503c\u3002 \u5982\u679c\u9700\u8981\u4f7f\u7528\u7a7a\u503c\u8fdb\u884c\u67e5\u8be2\uff0c\u8bf7\u4f7f\u7528 ${} \u8bed\u6cd5\u8bbe\u7f6e\u52a8\u6001\u503c\u3002 \u63a8\u8350\u5de5\u5177 \u82e5\u8981\u65b9\u4fbf\u5730\u8c03\u8bd5\u6b64\u7c7b\u95ee\u9898\uff0c\u5efa\u8bae\u5b89\u88c5 MyBatis Log \u63d2\u4ef6\u3002\u8be5\u63d2\u4ef6\u5c06\u5728\u63a7\u5236\u53f0\u4e2d\u6253\u5370\u8be6\u7ec6\u7684 SQL \u8bed\u53e5\u548c\u53c2\u6570\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u627e\u51fa\u95ee\u9898\u6240\u5728\u3002 \u4ee5\u4e0a\u5c31\u662fSpring Boot \u67e5\u8be2\u4e3a\u7a7a\uff0c\u5982\u4f55\u7528 MyBatis \u8bca\u65ad # [&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-7153","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7153","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=7153"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7153\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}