{"id":29502,"date":"2025-04-20T10:16:04","date_gmt":"2025-04-20T02:16:04","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/29502.html"},"modified":"2025-04-20T10:16:04","modified_gmt":"2025-04-20T02:16:04","slug":"%e3%80%90%e6%9c%8d%e5%8a%a1%e5%99%a8%e3%80%91mybatis%e6%98%af%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e5%b9%b6%e8%bf%9b%e8%a1%8c%e5%88%86%e9%a1%b5%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/29502.html","title":{"rendered":"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f"},"content":{"rendered":"<p>MyBatis \u662f\u4e00\u4e2a\u652f\u6301\u666e\u901a SQL \u67e5\u8be2\u3001\u5b58\u50a8\u8fc7\u7a0b\u548c\u9ad8\u7ea7\u6620\u5c04\u7684\u6301\u4e45\u5c42\u6846\u67b6\u3002\u5b83\u6d88\u9664\u4e86\u51e0\u4e4e\u6240\u6709\u7684 JDBC \u4ee3\u7801\u548c\u53c2\u6570\u7684\u624b\u52a8\u8bbe\u7f6e\u4ee5\u53ca\u7ed3\u679c\u96c6\u7684\u68c0\u7d22\u3002MyBatis \u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684 XML \u6216\u6ce8\u89e3\u6765\u914d\u7f6e\u548c\u6620\u5c04\u539f\u59cb\u7c7b\u578b\u3001\u63a5\u53e3\u548c Java \u7684 POJO&#xff08;Plain Old Java Objects&#xff0c;\u666e\u901a\u8001\u5f0f Java \u5bf9\u8c61&#xff09;\u5230\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u3002<\/p>\n<h4>MyBatis\u7684\u7279\u70b9<\/h4>\n<li>\n<p>SQL \u5206\u79bb&#xff1a;MyBatis \u5c06 SQL \u8bed\u53e5\u4ece Java \u4ee3\u7801\u4e2d\u5206\u79bb\u51fa\u6765&#xff0c;\u901a\u5e38\u653e\u5728 XML \u6587\u4ef6\u4e2d&#xff0c;\u4f7f\u5f97 SQL \u66f4\u52a0\u6e05\u6670&#xff0c;\u5e76\u4e14\u4fbf\u4e8e\u7ef4\u62a4\u3002<\/p>\n<\/li>\n<li>\n<p>\u7075\u6d3b\u7684\u6620\u5c04&#xff1a;\u63d0\u4f9b\u5f3a\u5927\u7684\u6620\u5c04\u529f\u80fd&#xff0c;\u80fd\u591f\u5c06 SQL \u67e5\u8be2\u7684\u7ed3\u679c\u76f4\u63a5\u6620\u5c04\u5230 Java \u5bf9\u8c61&#xff08;POJOs&#xff09;&#xff0c;\u5305\u62ec\u4e00\u5bf9\u4e00\u3001\u4e00\u5bf9\u591a\u7b49\u590d\u6742\u5173\u7cfb\u6620\u5c04\u3002<\/p>\n<\/li>\n<li>\n<p>\u52a8\u6001 SQL&#xff1a;\u652f\u6301\u57fa\u4e8e OGNL \u8868\u8fbe\u5f0f\u7684\u52a8\u6001 SQL \u6784\u5efa&#xff0c;\u5141\u8bb8\u6839\u636e\u4e0d\u540c\u7684\u6761\u4ef6\u751f\u6210\u4e0d\u540c\u7684 SQL \u8bed\u53e5\u3002<\/p>\n<\/li>\n<li>\n<p>\u63d2\u4ef6\u673a\u5236&#xff1a;\u901a\u8fc7\u63d2\u4ef6\u673a\u5236\u53ef\u4ee5\u5bf9 SQL \u6267\u884c\u8fc7\u7a0b\u8fdb\u884c\u62e6\u622a\u548c\u589e\u5f3a&#xff0c;\u6bd4\u5982\u5b9e\u73b0\u5206\u9875\u3001\u7f13\u5b58\u7b49\u529f\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0e Spring \u96c6\u6210&#xff1a;\u6613\u4e8e\u4e0e Spring \u7b49\u4e3b\u6d41\u6846\u67b6\u96c6\u6210&#xff0c;\u63d0\u4f9b\u4e8b\u52a1\u7ba1\u7406\u548c\u4f9d\u8d56\u6ce8\u5165\u7684\u652f\u6301\u3002<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u5e93\u72ec\u7acb\u6027&#xff1a;\u5c3d\u7ba1 MyBatis \u4e0d\u50cf Hibernate \u90a3\u6837\u63d0\u4f9b\u5b8c\u5168\u7684 ORM \u89e3\u51b3\u65b9\u6848&#xff0c;\u4f46\u5b83\u4ecd\u7136\u53ef\u4ee5\u5728\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u5e93\u4e4b\u95f4\u4fdd\u6301\u8f83\u9ad8\u7684\u79fb\u690d\u6027&#xff0c;\u53ea\u9700\u8981\u8c03\u6574\u76f8\u5e94\u7684 SQL \u8bed\u53e5\u6216\u4f7f\u7528\u63d2\u4ef6\u5982 PageHelper \u6765\u9002\u914d\u7279\u5b9a\u6570\u636e\u5e93\u7684\u65b9\u8a00\u3002<\/p>\n<\/li>\n<li>\n<p>\u6027\u80fd\u4f18\u5316&#xff1a;\u7531\u4e8e\u5b83\u662f\u534a\u81ea\u52a8\u5316\u7684\u6301\u4e45\u5c42\u6846\u67b6&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\u624b\u52a8\u7f16\u5199\u9ad8\u6548\u7684 SQL&#xff0c;\u4ece\u800c\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n<\/li>\n<h4>\u5728 Java \u4e2d\u4f7f\u7528 MyBatis \u8fdb\u884c\u5206\u9875<\/h4>\n<p>\u5728 Java \u4e2d\u4f7f\u7528 MyBatis \u8fdb\u884c\u5206\u9875\u67e5\u8be2&#xff0c;\u901a\u5e38\u4f1a\u7ed3\u5408\u6570\u636e\u5e93\u7684\u5206\u9875\u529f\u80fd\u6216\u4f7f\u7528\u7b2c\u4e09\u65b9\u63d2\u4ef6\u5982 PageHelper \u6765\u7b80\u5316\u5206\u9875\u903b\u8f91\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 PageHelper \u63d2\u4ef6\u8fdb\u884c\u5206\u9875\u7684\u57fa\u672c\u6b65\u9aa4&#xff1a;<\/p>\n<li>\n<p>\u5f15\u5165\u4f9d\u8d56&#xff1a; \u9996\u5148&#xff0c;\u5728\u9879\u76ee\u7684 pom.xml \u6587\u4ef6\u4e2d\u6dfb\u52a0 PageHelper \u548c MyBatis \u7684\u4f9d\u8d56\u3002<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e PageHelper&#xff1a; \u5728 MyBatis \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e PageHelper \u63d2\u4ef6&#xff0c;\u4f8b\u5982\u5728 mybatis-config.xml \u4e2d\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e&#xff1a;<\/p>\n<p> <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>plugins<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>plugin<\/span> <span class=\"token attr-name\">interceptor<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>com.github.pagehelper.PageInterceptor<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n    <span class=\"token comment\">&lt;!&#8211; \u914d\u7f6e\u53c2\u6570 &#8211;&gt;<\/span><br \/>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>plugin<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>plugins<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\n <\/li>\n<li>\n<p>\u7f16\u5199 Mapper \u63a5\u53e3&#xff1a; \u521b\u5efa\u5bf9\u5e94\u7684 Mapper \u63a5\u53e3&#xff0c;\u5e76\u5b9a\u4e49\u9700\u8981\u6267\u884c\u7684\u67e5\u8be2\u65b9\u6cd5\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p> <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">interface<\/span> <span class=\"token class-name\">UserMapper<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">List<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">selectUsers<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>\n <\/li>\n<li>\n<p>\u4f7f\u7528 PageHelper \u8fdb\u884c\u5206\u9875&#xff1a; \u5728\u8c03\u7528\u67e5\u8be2\u65b9\u6cd5\u4e4b\u524d&#xff0c;\u4f7f\u7528 PageHelper \u63d0\u4f9b\u7684\u65b9\u6cd5\u5f00\u59cb\u5206\u9875&#xff0c;\u6bd4\u5982 PageHelper.startPage(pageNum, pageSize)&#xff0c;\u5176\u4e2d pageNum \u662f\u9875\u7801&#xff0c;pageSize \u662f\u6bcf\u9875\u663e\u793a\u7684\u6570\u91cf\u3002<\/p>\n<p> <span class=\"token keyword\">import<\/span> <span class=\"token import\"><span class=\"token namespace\">com<span class=\"token punctuation\">.<\/span>github<span class=\"token punctuation\">.<\/span>pagehelper<span class=\"token punctuation\">.<\/span><\/span><span class=\"token class-name\">PageHelper<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token import\"><span class=\"token namespace\">com<span class=\"token punctuation\">.<\/span>github<span class=\"token punctuation\">.<\/span>pagehelper<span class=\"token punctuation\">.<\/span><\/span><span class=\"token class-name\">PageInfo<\/span><\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u8bbe\u7f6e\u5206\u9875\u53c2\u6570<\/span><br \/>\n<span class=\"token class-name\">PageHelper<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">startPage<\/span><span class=\"token punctuation\">(<\/span>pageNum<span class=\"token punctuation\">,<\/span> pageSize<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u6267\u884c\u67e5\u8be2<\/span><br \/>\n<span class=\"token class-name\">List<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> userList <span class=\"token operator\">&#061;<\/span> userMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">selectUsers<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u83b7\u53d6\u5206\u9875\u4fe1\u606f<\/span><br \/>\n<span class=\"token class-name\">PageInfo<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token class-name\">User<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> pageInfo <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">PageInfo<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token punctuation\">(<\/span>userList<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<li>\n<p>\u5904\u7406\u5206\u9875\u7ed3\u679c&#xff1a; \u4f7f\u7528 PageInfo \u7c7b\u6765\u83b7\u53d6\u5206\u9875\u540e\u7684\u6570\u636e&#xff0c;\u5305\u62ec\u603b\u8bb0\u5f55\u6570\u3001\u603b\u9875\u6570\u3001\u5f53\u524d\u9875\u7684\u6570\u636e\u5217\u8868\u7b49\u4fe1\u606f\u3002<\/p>\n<\/li>\n<h4>PageHelper\u63d2\u4ef6\u914d\u7f6e<\/h4>\n<p>PageHelper \u63d2\u4ef6\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u914d\u7f6e\u9009\u9879\u6765\u6ee1\u8db3\u4e0d\u540c\u7684\u5206\u9875\u9700\u6c42\u3002\u8fd9\u4e9b\u914d\u7f6e\u9879\u53ef\u4ee5\u5728 MyBatis \u7684\u5168\u5c40\u914d\u7f6e\u6587\u4ef6&#xff08;\u5982 mybatis-config.xml&#xff09;\u4e2d\u5b9a\u4e49&#xff0c;\u6216\u8005\u5728\u542f\u52a8 PageHelper \u65f6\u901a\u8fc7\u4ee3\u7801\u65b9\u5f0f\u8bbe\u7f6e\u3002\u4ee5\u4e0b\u662f PageHelper \u7684\u4e00\u4e9b\u4e3b\u8981\u914d\u7f6e\u53c2\u6570&#xff1a;<\/p>\n<li>\n<p>helperDialect&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e\u5e93\u65b9\u8a00&#xff0c;\u7528\u4e8e\u544a\u8bc9\u63d2\u4ef6\u4f7f\u7528\u54ea\u79cd\u6570\u636e\u5e93\u7684\u5206\u9875\u8bed\u6cd5\u3002\u4f8b\u5982&#xff1a;mysql, oracle, sqlserver \u7b49\u3002\u5982\u679c\u672a\u6307\u5b9a&#xff0c;\u63d2\u4ef6\u4f1a\u81ea\u52a8\u68c0\u6d4b\u5f53\u524d\u6570\u636e\u5e93\u7684\u65b9\u8a00&#xff0c;\u4f46\u63a8\u8350\u663e\u5f0f\u6307\u5b9a\u4ee5\u907f\u514d\u6f5c\u5728\u95ee\u9898\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>reasonable&#xff1a;<\/p>\n<ul>\n<li>\u5206\u9875\u5408\u7406\u5316&#xff0c;\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f00\u542f\u540e&#xff0c;\u5f53 pageNum &lt;&#061; 0 \u65f6\u4f1a\u81ea\u52a8\u8c03\u6574\u4e3a\u7b2c\u4e00\u9875&#xff1b;\u5f53 pageNum &gt; pages (\u603b\u9875\u6570)\u65f6\u4f1a\u81ea\u52a8\u8c03\u6574\u4e3a\u6700\u540e\u4e00\u9875\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>supportMethodsArguments&#xff1a;<\/p>\n<ul>\n<li>\u662f\u5426\u652f\u6301\u901a\u8fc7\u65b9\u6cd5\u53c2\u6570\u6765\u4f20\u9012\u5206\u9875\u53c2\u6570&#xff0c;\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f00\u542f\u540e\u53ef\u4ee5\u4e0d\u4f7f\u7528 PageHelper.startPage \u65b9\u6cd5&#xff0c;\u800c\u662f\u76f4\u63a5\u5728 Mapper \u63a5\u53e3\u7684\u65b9\u6cd5\u4e2d\u6dfb\u52a0\u5206\u9875\u53c2\u6570\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>params&#xff1a;<\/p>\n<ul>\n<li>\u81ea\u5b9a\u4e49\u53c2\u6570&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u6b64\u5c5e\u6027\u6765\u8986\u76d6\u9ed8\u8ba4\u7684\u5206\u9875\u53c2\u6570\u540d\u79f0\u3002\u4f8b\u5982&#xff1a;count&#061;countSql;pagehelper&#061;pageHelper&#xff0c;\u8fd9\u91cc\u6307\u5b9a\u4e86\u8ba1\u6570\u67e5\u8be2\u8bed\u53e5\u4e2d\u7684 count \u53c2\u6570\u548c\u5206\u9875\u52a9\u624b\u7684\u522b\u540d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>autoRuntimeDialect&#xff1a;<\/p>\n<ul>\n<li>\u662f\u5426\u81ea\u52a8\u8bc6\u522b\u6570\u636e\u5e93\u65b9\u8a00&#xff0c;\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5982\u679c\u5f00\u542f\u4e86\u8fd9\u4e2a\u9009\u9879&#xff0c;\u5219\u4e0d\u9700\u8981\u624b\u52a8\u6307\u5b9a helperDialect&#xff0c;\u63d2\u4ef6\u4f1a\u6839\u636e\u8fd0\u884c\u65f6\u7684\u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f\u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684\u65b9\u8a00\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>closeConn&#xff1a;<\/p>\n<ul>\n<li>\u6267\u884c\u5206\u9875\u540e\u662f\u5426\u5173\u95ed\u8fde\u63a5&#xff0c;\u9ed8\u8ba4\u503c\u4e3a true\u3002\u5bf9\u4e8e\u67d0\u4e9b\u7279\u6b8a\u573a\u666f&#xff0c;\u6bd4\u5982\u6267\u884c\u5b58\u50a8\u8fc7\u7a0b\u65f6&#xff0c;\u53ef\u80fd\u9700\u8981\u5c06\u6b64\u9009\u9879\u8bbe\u4e3a false\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>offsetAsPageNum&#xff1a;<\/p>\n<ul>\n<li>\u662f\u5426\u628a offset \u5f53\u4f5c\u9875\u7801\u6765\u4f7f\u7528&#xff0c;\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5982\u679c\u8bbe\u4e3a true&#xff0c;\u5219\u5206\u9875\u63d2\u4ef6\u4f1a\u81ea\u52a8\u8ba1\u7b97\u51fa\u6b63\u786e\u7684 offset \u548c limit\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>rowBoundsWithCount&#xff1a;<\/p>\n<ul>\n<li>\u662f\u5426\u8fdb\u884c\u8bb0\u5f55\u603b\u6570\u67e5\u8be2&#xff0c;\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f00\u542f\u540e\u6bcf\u6b21\u5206\u9875\u90fd\u4f1a\u81ea\u52a8\u67e5\u8be2\u4e00\u6b21\u603b\u6570&#xff0c;\u9002\u7528\u4e8e\u9700\u8981\u663e\u793a\u603b\u9875\u6570\u6216\u603b\u8bb0\u5f55\u6570\u7684\u573a\u5408\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>pageSizeZero&#xff1a;<\/p>\n<ul>\n<li>\u5f53 pageSize &#061; 0 \u6216 pageSize &lt; 0 \u65f6&#xff0c;\u662f\u5426\u8fd4\u56de\u5168\u90e8\u7ed3\u679c&#xff0c;\u9ed8\u8ba4\u503c\u4e3a false\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>reasonableAdjust&#xff1a;<\/p>\n<ul>\n<li>\u662f\u5426\u542f\u7528\u5408\u7406\u7684\u8c03\u6574&#xff0c;\u9ed8\u8ba4\u503c\u4e3a true\u3002\u5b83\u4f1a\u5f71\u54cd reasonable \u5c5e\u6027\u7684\u884c\u4e3a&#xff0c;\u5373\u5f53 pageNum &lt;&#061; 0 \u6216 pageNum &gt; pages \u65f6\u5982\u4f55\u5904\u7406\u3002<\/li>\n<\/ul>\n<\/li>\n<p>\u8fd9\u4e9b\u914d\u7f6e\u9879\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u597d\u5730\u63a7\u5236\u5206\u9875\u884c\u4e3a&#xff0c;\u786e\u4fdd\u5206\u9875\u903b\u8f91\u7b26\u5408\u5177\u4f53\u7684\u5e94\u7528\u9700\u6c42\u3002\u901a\u5e38\u60c5\u51b5\u4e0b&#xff0c;\u9ed8\u8ba4\u914d\u7f6e\u5df2\u7ecf\u80fd\u591f\u6ee1\u8db3\u5927\u90e8\u5206\u5e94\u7528\u7684\u9700\u6c42&#xff0c;\u4f46\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u9002\u5f53\u7684\u914d\u7f6e\u8c03\u6574\u662f\u5fc5\u8981\u7684\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420021602-680458e2a8860.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>\u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul>\n<li>PageHelper \u9ed8\u8ba4\u9002\u7528\u4e8e MySQL \u6570\u636e\u5e93\u3002\u5982\u679c\u4f7f\u7528\u5176\u4ed6\u7c7b\u578b\u7684\u6570\u636e\u5e93&#xff0c;\u53ef\u80fd\u9700\u8981\u6839\u636e\u5177\u4f53\u6570\u636e\u5e93\u8c03\u6574\u5206\u9875\u63d2\u4ef6\u7684\u914d\u7f6e\u3002<\/li>\n<li>\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e2d\u4f7f\u7528 PageHelper \u65f6\u8981\u786e\u4fdd\u7ebf\u7a0b\u5b89\u5168&#xff0c;\u56e0\u4e3a\u5206\u9875\u53c2\u6570\u662f\u57fa\u4e8e ThreadLocal \u5b58\u50a8\u7684\u3002<\/li>\n<li>\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u5b58\u5728\u4e8b\u52a1\u7ba1\u7406&#xff0c;\u5219\u9700\u8981\u6ce8\u610f PageHelper \u5206\u9875\u64cd\u4f5c\u4e0e\u4e8b\u52a1\u4e4b\u95f4\u7684\u4ea4\u4e92&#xff0c;\u786e\u4fdd\u4e0d\u4f1a\u4ea7\u751f\u610f\u5916\u7684\u884c\u4e3a\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e14\u6b21\uff0c\u6536\u85cf14\u6b21\u3002MyBatis \u662f\u4e00\u4e2a\u652f\u6301\u666e\u901a SQL \u67e5\u8be2\u3001\u5b58\u50a8\u8fc7\u7a0b\u548c\u9ad8\u7ea7\u6620\u5c04\u7684\u6301\u4e45\u5c42\u6846\u67b6\u3002\u5b83\u6d88\u9664\u4e86\u51e0\u4e4e\u6240\u6709\u7684 JDBC \u4ee3\u7801\u548c\u53c2\u6570\u7684\u624b\u52a8\u8bbe\u7f6e\u4ee5\u53ca\u7ed3\u679c\u96c6\u7684\u68c0\u7d22\u3002MyBatis \u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684 XML \u6216\u6ce8\u89e3\u6765\u914d\u7f6e\u548c\u6620\u5c04\u539f\u59cb\u7c7b\u578b\u3001\u63a5\u53e3\u548c Java \u7684 POJO\uff08Plain Old Java Objects\uff0c\u666e\u901a\u8001\u5f0f Java \u5bf9\u8c61\uff09\u5230\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u3002_java \u5e95\u5c42\u6620\u5c04\u5b9e\u73b0mybaits\u5206\u9875<\/p>\n","protected":false},"author":2,"featured_media":29501,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,1769,43,2096],"topic":[],"class_list":["post-29502","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-mybatis","tag-43","tag-2096"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/29502.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e14\u6b21\uff0c\u6536\u85cf14\u6b21\u3002MyBatis \u662f\u4e00\u4e2a\u652f\u6301\u666e\u901a SQL \u67e5\u8be2\u3001\u5b58\u50a8\u8fc7\u7a0b\u548c\u9ad8\u7ea7\u6620\u5c04\u7684\u6301\u4e45\u5c42\u6846\u67b6\u3002\u5b83\u6d88\u9664\u4e86\u51e0\u4e4e\u6240\u6709\u7684 JDBC \u4ee3\u7801\u548c\u53c2\u6570\u7684\u624b\u52a8\u8bbe\u7f6e\u4ee5\u53ca\u7ed3\u679c\u96c6\u7684\u68c0\u7d22\u3002MyBatis \u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684 XML \u6216\u6ce8\u89e3\u6765\u914d\u7f6e\u548c\u6620\u5c04\u539f\u59cb\u7c7b\u578b\u3001\u63a5\u53e3\u548c Java \u7684 POJO\uff08Plain Old Java Objects\uff0c\u666e\u901a\u8001\u5f0f Java \u5bf9\u8c61\uff09\u5230\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u3002_java \u5e95\u5c42\u6620\u5c04\u5b9e\u73b0mybaits\u5206\u9875\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/29502.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-20T02:16:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420021602-680458e2a8860.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/29502.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/29502.html\",\"name\":\"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-20T02:16:04+00:00\",\"dateModified\":\"2025-04-20T02:16:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/29502.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/29502.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/29502.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/29502.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e14\u6b21\uff0c\u6536\u85cf14\u6b21\u3002MyBatis \u662f\u4e00\u4e2a\u652f\u6301\u666e\u901a SQL \u67e5\u8be2\u3001\u5b58\u50a8\u8fc7\u7a0b\u548c\u9ad8\u7ea7\u6620\u5c04\u7684\u6301\u4e45\u5c42\u6846\u67b6\u3002\u5b83\u6d88\u9664\u4e86\u51e0\u4e4e\u6240\u6709\u7684 JDBC \u4ee3\u7801\u548c\u53c2\u6570\u7684\u624b\u52a8\u8bbe\u7f6e\u4ee5\u53ca\u7ed3\u679c\u96c6\u7684\u68c0\u7d22\u3002MyBatis \u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684 XML \u6216\u6ce8\u89e3\u6765\u914d\u7f6e\u548c\u6620\u5c04\u539f\u59cb\u7c7b\u578b\u3001\u63a5\u53e3\u548c Java \u7684 POJO\uff08Plain Old Java Objects\uff0c\u666e\u901a\u8001\u5f0f Java \u5bf9\u8c61\uff09\u5230\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u3002_java \u5e95\u5c42\u6620\u5c04\u5b9e\u73b0mybaits\u5206\u9875","og_url":"https:\/\/www.wsisp.com\/helps\/29502.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-20T02:16:04+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420021602-680458e2a8860.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/29502.html","url":"https:\/\/www.wsisp.com\/helps\/29502.html","name":"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-20T02:16:04+00:00","dateModified":"2025-04-20T02:16:04+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/29502.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/29502.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/29502.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u670d\u52a1\u5668\u3011MyBatis\u662f\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u5e76\u8fdb\u884c\u5206\u9875\u7684\uff1f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/29502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=29502"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/29502\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/29501"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=29502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=29502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=29502"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=29502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}