{"id":200410,"date":"2025-05-06T09:54:55","date_gmt":"2025-05-06T01:54:55","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200410\/"},"modified":"2025-05-06T09:54:55","modified_gmt":"2025-05-06T01:54:55","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","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200410\/","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><b><\/b> <\/p>\n<h1>Spring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u5411\u5927\u5bb6\u4ecb\u7ecd\u300aSpring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\uff1f\u300b\uff0c\u4e3b\u8981\u5305\u62ec\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241104\/1730708140672882ac33676.jpg\" class=\"aligncenter\"><\/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\u533a\u522b<\/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>\u4eca\u5929\u5173\u4e8e\u300aSpring Boot \u67e5\u8be2 SQL \u4e3a\u7a7a\uff1aIDEA \u67e5\u8be2\u5931\u8d25\uff0cNavicat \u5374\u6210\u529f\uff0c\u5982\u4f55\u6392\u67e5\uff1f\u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot \u67e5\u8be2 S&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200410","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200410"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200410\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}