{"id":25400,"date":"2024-11-24T11:27:07","date_gmt":"2024-11-24T03:27:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25400\/"},"modified":"2024-11-24T11:27:07","modified_gmt":"2024-11-24T03:27:07","slug":"spring-boot-%e6%9f%a5%e8%af%a2-sql-%e4%b8%ba%e7%a9%ba%ef%bc%9aidea-%e6%9f%a5%e8%af%a2%e5%a4%b1%e8%b4%a5%ef%bc%8cnavicat-%e5%8d%b4%e6%88%90%e5%8a%9f%ef%bc%8c%e5%a6%82%e4%bd%95%e6%8e%92%e6%9f%a5-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25400\/","title":{"rendered":"Spring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173060714427168.jpg\" class=\"aligncenter\" title=\"Spring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\uff1f\u63d2\u56fe\" alt=\"Spring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>Spring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1a\u8bca\u65ad\u548c\u89e3\u51b3<\/strong><\/p>\n<p>\u5728 Spring Boot \u5e94\u7528\u4e2d\u9047\u5230 SQL \u67e5\u8be2\u4e3a\u7a7a\u7684\u95ee\u9898\u65f6\uff0c\u9700\u8981\u6df1\u5165\u6392\u67e5\uff0c\u786e\u5b9a\u95ee\u9898\u7684\u6839\u6e90\u3002\u672c\u6587\u5c06\u63d0\u4f9b\u4e00\u4e9b\u8bca\u65ad\u548c\u89e3\u51b3\u601d\u8def\u3002<\/p>\n<p>\u4ece\u4f60\u63d0\u4f9b\u7684\u4e0a\u4e0b\u6587\u6765\u770b\uff0c\u5728 IDEA \u4e2d\u67e5\u8be2\u8fd4\u56de\u7a7a\uff0c\u800c\u4f7f\u7528 Navicat \u6267\u884c\u76f8\u540c SQL \u5374\u80fd\u6210\u529f\u67e5\u8be2\u5230\u6570\u636e\u3002\u8fd9\u8868\u660e\u95ee\u9898\u53ef\u80fd\u51fa\u5728 Java \u4ee3\u7801\u4e2d\u3002<\/p>\n<p><strong>\u9996\u5148\uff0c\u68c0\u67e5 SQL \u8bed\u53e5\u7684\u8bed\u6cd5\u548c\u53c2\u6570\u4f20\u9012<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd SQL \u8bed\u53e5\u7684\u8bed\u6cd5\u6b63\u786e\uff0c\u5e76\u4e14\u4f7f\u7528\u7684\u662f\u6b63\u786e\u7684\u53c2\u6570\u7c7b\u578b\u3002<\/li>\n<li>\u9a8c\u8bc1\u5728 Java \u4ee3\u7801\u4e2d\u4f20\u9012\u7ed9 SQL \u8bed\u53e5\u7684\u53c2\u6570\u4e0e\u6570\u636e\u5e93\u4e2d\u5b58\u5728\u7684\u5b57\u6bb5\u7c7b\u578b\u76f8\u5339\u914d\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u6b21\uff0c\u8003\u8651 MyBatis \u7684 # \u548c $ \u5360\u4f4d\u7b26\u7684<\/strong><\/p>\n<ul>\n<li>MyBatis \u4f7f\u7528 #{} \u5360\u4f4d\u7b26\u7ed1\u5b9a\u53c2\u6570\uff0c\u6267\u884c\u65f6\u66ff\u6362\u4e3a\u5177\u4f53\u503c\u3002<\/li>\n<li>MyBatis \u4f7f\u7528 ${} \u5360\u4f4d\u7b26\u63d2\u5165\u503c\uff0c\u6267\u884c\u65f6\u539f\u6837\u4fdd\u7559\u3002<\/li>\n<\/ul>\n<p>\u6839\u636e\u4f60\u7684\u63cf\u8ff0\uff0c\u4f7f\u7528\u7a7a where \u5b50\u53e5\u53ef\u4ee5\u67e5\u5230\u6570\u636e\u3002\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a MyBatis \u5c06 where \u5b50\u53e5\u4e2d\u7684\u53c2\u6570\u89e3\u91ca\u4e3a\u5b57\u7b26\u4e32\uff0c\u800c\u4e0d\u662f\u53d8\u91cf\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 #{} \u5360\u4f4d\u7b26\u7ed1\u5b9a\u6240\u6709\u53c2\u6570\uff0c\u4ee5\u786e\u4fdd\u52a8\u6001\u66ff\u6362\u3002<\/li>\n<li>\u5b89\u88c5 MyBatis Log \u63d2\u4ef6\uff0c\u4ee5\u4fbf\u5728\u65e5\u5fd7\u4e2d\u67e5\u770b\u751f\u6210\u7684 SQL \u8bed\u53e5\u548c\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fSpring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\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>Spring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1a\u8bca\u65ad\u548c\u89e3\u51b3 \u5728 Spring Boot \u5e94\u7528\u4e2d\u9047\u5230 SQL \u67e5\u8be2\u4e3a\u7a7a\u7684\u95ee\u9898\u65f6\uff0c\u9700\u8981\u6df1\u5165\u6392\u67e5\uff0c\u786e\u5b9a\u95ee\u9898\u7684\u6839\u6e90\u3002\u672c\u6587\u5c06\u63d0\u4f9b\u4e00\u4e9b\u8bca\u65ad\u548c\u89e3\u51b3\u601d\u8def\u3002 \u4ece\u4f60\u63d0\u4f9b\u7684\u4e0a\u4e0b\u6587\u6765\u770b\uff0c\u5728 IDEA \u4e2d\u67e5\u8be2\u8fd4\u56de\u7a7a\uff0c\u800c\u4f7f\u7528 Navicat \u6267\u884c\u76f8\u540c SQL \u5374\u80fd\u6210\u529f\u67e5\u8be2\u5230\u6570\u636e\u3002\u8fd9\u8868\u660e\u95ee\u9898\u53ef\u80fd\u51fa\u5728 Java \u4ee3\u7801\u4e2d\u3002 \u9996\u5148\uff0c\u68c0\u67e5 SQL \u8bed\u53e5\u7684\u8bed\u6cd5\u548c\u53c2\u6570\u4f20\u9012 \u786e\u4fdd SQL \u8bed\u53e5\u7684\u8bed\u6cd5\u6b63\u786e\uff0c\u5e76\u4e14\u4f7f\u7528\u7684\u662f\u6b63\u786e\u7684\u53c2\u6570\u7c7b\u578b\u3002 \u9a8c\u8bc1\u5728 Java \u4ee3\u7801\u4e2d\u4f20\u9012\u7ed9 SQL \u8bed\u53e5\u7684\u53c2\u6570\u4e0e\u6570\u636e\u5e93\u4e2d\u5b58\u5728\u7684\u5b57\u6bb5\u7c7b\u578b\u76f8\u5339\u914d\u3002 \u5176\u6b21\uff0c\u8003\u8651 MyBatis \u7684 # \u548c $ \u5360\u4f4d\u7b26\u7684 MyBatis \u4f7f\u7528 #{} \u5360\u4f4d\u7b26\u7ed1\u5b9a\u53c2\u6570\uff0c\u6267\u884c\u65f6\u66ff\u6362\u4e3a\u5177\u4f53\u503c\u3002 MyBatis \u4f7f\u7528 ${} \u5360\u4f4d\u7b26\u63d2\u5165\u503c\uff0c\u6267\u884c\u65f6\u539f\u6837\u4fdd\u7559\u3002 \u6839\u636e\u4f60\u7684\u63cf\u8ff0\uff0c\u4f7f\u7528\u7a7a where \u5b50\u53e5\u53ef\u4ee5\u67e5\u5230\u6570\u636e\u3002\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3a MyBatis \u5c06 where \u5b50\u53e5\u4e2d\u7684\u53c2\u6570\u89e3\u91ca\u4e3a\u5b57\u7b26\u4e32\uff0c\u800c\u4e0d\u662f\u53d8\u91cf\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u4f7f\u7528 [&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-25400","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25400","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=25400"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25400\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}