{"id":416,"date":"2020-12-06T01:26:24","date_gmt":"2020-12-05T17:26:24","guid":{"rendered":"http:\/\/moyisuiying.com\/?p=416"},"modified":"2020-12-10T14:23:35","modified_gmt":"2020-12-10T06:23:35","slug":"mybatis-plus%e5%ad%a6%e4%b9%a0%ef%bc%88%e4%b8%83%ef%bc%89-mybatiplus%e7%9a%84%e4%bb%a3%e7%a0%81%e7%94%9f%e6%88%90%e5%99%a8","status":"publish","type":"post","link":"http:\/\/moyisuiying.com\/index.php\/mybatis\/416.html","title":{"rendered":"Mybatis-plus\u5b66\u4e60\uff08\u4e03\uff09\u2014\u2014MybatiPlus\u7684\u4ee3\u7801\u751f\u6210\u5668"},"content":{"rendered":"\n<h2>7.\u4ee3\u7801\u751f\u6210\u5668<\/h2>\n\n\n\n<p>AutoGenerator \u662f MyBatis-Plus \u7684\u4ee3\u7801\u751f\u6210\u5668\uff0c\u901a\u8fc7 AutoGenerator \u53ef\u4ee5\u5feb\u901f\u751f\u6210 Entity\u3001Mapper\u3001Mapper XML\u3001Service\u3001Controller \u7b49\u5404\u4e2a\u6a21\u5757\u7684\u4ee3\u7801\uff0c\u6781\u5927\u7684\u63d0\u5347\u4e86\u5f00\u53d1\u6548\u7387\u3002<\/p>\n\n\n\n<p>\u7279\u522b\u8bf4\u660e:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u81ea\u5b9a\u4e49\u6a21\u677f\u6709\u54ea\u4e9b\u53ef\u7528\u53c2\u6570\uff1f<a href=\"https:\/\/github.com\/baomidou\/mybatis-plus\/blob\/3.0\/mybatis-plus-generator\/src\/main\/java\/com\/baomidou\/mybatisplus\/generator\/engine\/AbstractTemplateEngine.java\" target=\"_blank\"  rel=\"nofollow\" >Github<\/a> <a href=\"https:\/\/gitee.com\/baomidou\/mybatis-plus\/blob\/3.0\/mybatis-plus-generator\/src\/main\/java\/com\/baomidou\/mybatisplus\/generator\/engine\/AbstractTemplateEngine.java\" target=\"_blank\"  rel=\"nofollow\" >Gitee<\/a> AbstractTemplateEngine \u7c7b\u4e2d\u65b9\u6cd5 getObjectMap \u8fd4\u56de objectMap \u7684\u6240\u6709\u503c\u90fd\u53ef\u7528\u3002<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.moyisuiying.booksystem;\n\nimport com.baomidou.mybatisplus.annotation.DbType;\nimport com.baomidou.mybatisplus.annotation.FieldFill;\nimport com.baomidou.mybatisplus.generator.AutoGenerator;\nimport com.baomidou.mybatisplus.generator.config.*;\nimport com.baomidou.mybatisplus.generator.config.po.TableFill;\nimport com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;\nimport com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;\nimport java.util.ArrayList;\n\n\/**\n * Classname:GenerateCodeTest\n *\n * @description:\u6f14\u793a\u4f8b\u5b50\uff0c\u6267\u884c main \u65b9\u6cd5\u63a7\u5236\u53f0\u8f93\u5165\u6a21\u5757\u8868\u540d\u56de\u8f66\u81ea\u52a8\u751f\u6210\u5bf9\u5e94\u9879\u76ee\u76ee\u5f55\u4e2d\n * @author: \u964c\u610f\u968f\u5f71\n * @Date: 2020-11-25 23:54\n * @Version: 1.0\n **\/\n\n\/\/\npublic class CodeGeneratorTest {\n\n    public static void main(String&#91;] args) {\n        \/\/ \u4ee3\u7801\u751f\u6210\u5668\n        AutoGenerator mpg = new AutoGenerator();\n\n        \/\/ \u5168\u5c40\u914d\u7f6e\n        GlobalConfig gc = new GlobalConfig();\n\/\/        String projectPath = System.getProperty(\"user.dir\");\n\/\/        \u9879\u76ee\u7684\u6839\u8def\u5f84\n        String projectPath = \"E:\\\\\u65b0\u6280\u672f\u5b66\u4e60\\\\java_study\\\\mybatis-plus\u5b66\u4e60\\\\booksystemWeb\";\n\/\/        \u8bbe\u7f6e\u8f93\u51fa\u76ee\u5f55\n        gc.setOutputDir(projectPath + \"\/src\/main\/java\");\n\/\/        \u8bbe\u7f6e\u4f5c\u8005\n        gc.setAuthor(\"\u964c\u610f\u968f\u5f71\");\n\/\/        \u8bbe\u7f6e\u662f\u5426\u6253\u5f00\n        gc.setOpen(false);\n        \/\/\u7b2c\u4e8c\u6b21\u751f\u6210\u7684\u628a\u7b2c\u4e00\u6b21\u8986\u76d6\u6389\n        gc.setFileOverride(true);\n        \/\/mapper \u547d\u540d\u65b9\u5f0f,\u9ed8\u8ba4\u503c\uff1anull \u4f8b\u5982\uff1a%sDao \u751f\u6210 UserDao\n        gc.setMapperName(\"%sMapper\");\n        \/\/\u751f\u6210\u7684service\u63a5\u53e3\u540d\u5b57\u9996\u5b57\u6bcd\u662f\u5426\u4e3aI\uff0c\u8fd9\u6837\u8bbe\u7f6e\u5c31\u6ca1\u6709I\n        gc.setServiceName(\"%sService\");\n        \/\/service impl \u547d\u540d\u65b9\u5f0f\uff0c\u9ed8\u8ba4\u503c\uff1anull \u4f8b\u5982\uff1a%sBusinessImpl \u751f\u6210 UserBusinessImpl\n        gc.setServiceImplName(null);\n\n        \/\/ gc.setSwagger2(true); \u5b9e\u4f53\u5c5e\u6027 Swagger2 \u6ce8\u89e3\n        gc.setSwagger2(true);\n        mpg.setGlobalConfig(gc);\n\n        \/\/ \u6570\u636e\u6e90\u914d\u7f6e\n        DataSourceConfig dsc = new DataSourceConfig();\n\/\/        \u8bbe\u7f6e\u6570\u636e\u7684URL\n        dsc.setUrl(\"jdbc:mysql:\/\/localhost:3306\/javaweb?serverTimezone=UTC&amp;useUnicode=true&amp;useSSL=false&amp;characterEncoding=utf8\");\n        \/\/ dsc.setSchemaName(\"public\");\n\/\/        \u8bbe\u7f6e\u6570\u636e\u5e93\u7684\u9a71\u52a8\n        dsc.setDriverName(\"com.mysql.cj.jdbc.Driver\");\n\/\/        \u8bbe\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u7528\u6237\u540d\n        dsc.setUsername(\"root\");\n\/\/        \u8bbe\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u7528\u5bc6\u7801\n        dsc.setPassword(\"root\");\n\/\/        \u8bbe\u7f6e\u6570\u636e\u5e93\u7c7b\u578b\n        dsc.setDbType(DbType.MYSQL);\n        mpg.setDataSource(dsc);\n\n        \/\/ \u5305\u914d\u7f6e\n        PackageConfig pc = new PackageConfig();\n\/\/        \u8bbe\u7f6e\u9879\u76ee\u6a21\u5757\u540d\n        pc.setModuleName(\"booksystem\");\n\/\/        \u8bbe\u7f6e\u7236\u7c7b\u540d\n        pc.setParent(\"com.moyisuiying\");\n\/\/        \u8bbe\u7f6e\u5b9e\u4f53\u7c7b\u5305\u540d\n        pc.setEntity(\"entity\");\n\/\/        \u8bbe\u7f6e\u63a7\u5236\u5668\u5305\u540d\n        pc.setController(\"controller\");\n\/\/        \u8bbe\u7f6e\u4e1a\u52a1\u903b\u8f91\u5305\u540d\n        pc.setService(\"service\");\n\/\/        \u8bbe\u7f6emapper\u7684\u5305\u540d\n        pc.setMapper(\"mapper\");\n        mpg.setPackageInfo(pc);\n\n\n        \/\/ \u7b56\u7565\u914d\u7f6e\n        StrategyConfig strategy = new StrategyConfig();\n\/\/        \u8bbe\u7f6e\u8868\u540d\u5230\u5b9e\u4f53\u7c7b\u95f4\u7684\u6620\u5c04\u89c4\u5219\uff0c\u8868AccountPart \u5230\u5b9e\u4f53\u7c7b\u7684 \u8868AccountPart\u662f\u4e00\u81f4\u7684\uff0c\u6ca1\u8fd8\u6709\u53d1\u751f\u53d8\u5316\n        strategy.setNaming(NamingStrategy.no_change);\n\/\/        \u8bbe\u7f6e\u8868\u7684\u5217\u5c5e\u6027\u5230\u5b9e\u4f53\u7c7b\u5c5e\u6027\u540d\u7684\u6620\u5c04\u89c4\u5219\uff0c\u8fd9\u91cc\u8bbe\u7f6e\u4e86\u6ca1\u6709\u6539\u53d8\uff0c\u6bd4\u5982 \u8868\u4e2d\u7684 nickName \u5230\u5b9e\u4f53\u7c7b\u7684 nickName\u662f\u4e00\u81f4\u7684\uff0c\u6ca1\u8fd8\u6709\u53d1\u751f\u53d8\u5316\n        strategy.setColumnNaming(NamingStrategy.no_change);\n\/\/        strategy.setSuperEntityClass();\n\/\/        \u7ed9\u5b9e\u4f53\u7c7b\u8bbe\u7f6e\u81ea\u52a8lombok\n        strategy.setEntityLombokModel(true);\n\/\/        \u751f\u6210@RestController\u63a7\u5236\u5668\n        strategy.setRestControllerStyle(true);\n        \/\/ \u516c\u5171\u7236\u7c7b\n\/\/        strategy.setSuperControllerClass(\"\u4f60\u81ea\u5df1\u7684\u7236\u7c7b\u63a7\u5236\u5668,\u6ca1\u6709\u5c31\u4e0d\u7528\u8bbe\u7f6e!\");\n        \/\/ \u5199\u4e8e\u7236\u7c7b\u4e2d\u7684\u516c\u5171\u5b57\u6bb5\n        strategy.setSuperEntityColumns(\"id\");\n\/\/        \u8bbe\u7f6e\u8981\u6620\u5c04\u7684\u6570\u636e\u5e93\u8868\u540d\n        strategy.setInclude(\"account\",\"book\",\"borrowbook\");\n\/\/        \u8bbe\u7f6e\u903b\u8f91\u5220\u9664\u7684\u5b57\u6bb5\u540d\u79f0\n        strategy.setLogicDeleteFieldName(\"deleted\");\n\/\/        \u8bbe\u7f6e\u4e50\u89c2\u9501\n        strategy.setVersionFieldName(\"version\");\n        strategy.setControllerMappingHyphenStyle(true);\n        \/\/ \u81ea\u52a8\u586b\u5145\u914d\u7f6e\n        TableFill gmtCreate = new TableFill(\"createTime\", FieldFill.INSERT);\n        TableFill gmtModified = new TableFill(\"updateTime\",FieldFill.INSERT_UPDATE);\n        ArrayList&lt;TableFill> tableFills = new ArrayList&lt;>();\n        tableFills.add(gmtCreate);\n        tableFills.add(gmtModified);\n        strategy.setTableFillList(tableFills);\n        mpg.setStrategy(strategy);\n        mpg.setTemplateEngine(new FreemarkerTemplateEngine());\n        \/\/\u6267\u884c\u751f\u6210\u4ee3\u7801\n        mpg.execute();\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>\u521b\u5efa\u8fc7\u7a0b\u4e2d\u9700\u8981\u7528\u5230\u7684\u4e09\u4e2a\u5b8c\u6574\u7684\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE `account` (\n  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id\u4e3b\u952e\uff0c\u81ea\u589e',\n  `name` varchar(32) DEFAULT NULL,\n  `password` varchar(50) NOT NULL COMMENT '\u5bc6\u7801',\n  `createTime` datetime DEFAULT CURRENT_TIMESTAMP,\n  `status` int(11) DEFAULT '0',\n  `type` int(11) DEFAULT NULL,\n  `sex` varchar(4) DEFAULT NULL,\n  `hobby` varchar(128) DEFAULT NULL,\n  `signature` varchar(128) DEFAULT NULL,\n  `age` int(4) DEFAULT NULL,\n  `deleted` tinyint(1) NOT NULL DEFAULT '0',\n  `version` int(11) NOT NULL DEFAULT '1',\n  `updateTime` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4',\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `name` (`name`)\n) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COMMENT='\u7528\u6237\u8868';\n\nCREATE TABLE `book` (\n  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id\u4e3b\u952e\uff0c\u81ea\u589e',\n  `name` varchar(50) NOT NULL COMMENT '\u4e66\u540d',\n  `author` varchar(50) NOT NULL COMMENT '\u4f5c\u8005',\n  `price` double NOT NULL COMMENT '\u4ef7\u683c',\n  `type` varchar(10) DEFAULT NULL,\n  `status` int(11) DEFAULT '0',\n  `description` varchar(128) DEFAULT NULL,\n  `sbn` varchar(32) DEFAULT NULL,\n  `createTime` datetime DEFAULT NULL,\n  `version` int(11) NOT NULL DEFAULT '1',\n  `updateTime` datetime DEFAULT NULL COMMENT '\u66f4\u65b0\u65f6\u95f4',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=62 DEFAULT CHARSET=utf8 COMMENT='\u4e66\u7c4d\u8868';\n\nCREATE TABLE `borrowbook` (\n  `accountid` int(11) DEFAULT NULL,\n  `bookid` int(11) DEFAULT NULL,\n  `borrowtime` datetime DEFAULT NULL,\n  `returntime` datetime DEFAULT NULL,\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `version` int(11) NOT NULL DEFAULT '1',\n  `updateTime` datetime DEFAULT NULL COMMENT '\u4fee\u6539\u65f6\u95f4',\n  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '\u903b\u8f91\u5220\u9664\u6807\u8bc6',\n  `createTime` datetime DEFAULT NULL COMMENT '\u521b\u5efa\u65f6\u95f4',\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;<\/code><\/pre>\n\n\n\n<h3>7.1\u4f7f\u7528\u6559\u7a0b<\/h3>\n\n\n\n<p>MyBatis-Plus \u4ece <code>3.0.3<\/code> \u4e4b\u540e\u79fb\u9664\u4e86\u4ee3\u7801\u751f\u6210\u5668\u4e0e\u6a21\u677f\u5f15\u64ce\u7684\u9ed8\u8ba4\u4f9d\u8d56\uff0c\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u76f8\u5173\u4f9d\u8d56\uff1a<\/p>\n\n\n\n<h4>7.1.1\u6dfb\u52a0 \u4ee3\u7801\u751f\u6210\u5668 \u4f9d\u8d56<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency>\n    &lt;groupId>com.baomidou&lt;\/groupId>\n    &lt;artifactId>mybatis-plus-generator&lt;\/artifactId>\n    &lt;version>3.4.1&lt;\/version>\n&lt;\/dependency><\/code><\/pre>\n\n\n\n<h4>7.1.2\u6dfb\u52a0 \u6a21\u677f\u5f15\u64ce \u4f9d\u8d56\uff0cMyBatis-Plus \u652f\u6301 Velocity\uff08\u9ed8\u8ba4\uff09\u3001Freemarker\u3001Beetl\uff0c\u7528\u6237\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u719f\u6089\u7684\u6a21\u677f\u5f15\u64ce\uff0c\u5982\u679c\u90fd\u4e0d\u6ee1\u8db3\u60a8\u7684\u8981\u6c42\uff0c\u53ef\u4ee5\u91c7\u7528\u81ea\u5b9a\u4e49\u6a21\u677f\u5f15\u64ce\u3002<\/h4>\n\n\n\n<p>Velocity\uff08\u9ed8\u8ba4\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency>\n    &lt;groupId>org.apache.velocity&lt;\/groupId>\n    &lt;artifactId>velocity-engine-core&lt;\/artifactId>\n    &lt;version>2.2&lt;\/version>\n&lt;\/dependency><\/code><\/pre>\n\n\n\n<p>Freemarker\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency>\n    &lt;groupId>org.freemarker&lt;\/groupId>\n    &lt;artifactId>freemarker&lt;\/artifactId>\n    &lt;version>2.3.30&lt;\/version>\n&lt;\/dependency><\/code><\/pre>\n\n\n\n<p>Beetl\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency>\n    &lt;groupId>com.ibeetl&lt;\/groupId>\n    &lt;artifactId>beetl&lt;\/artifactId>\n    &lt;version>3.2.4.RELEASE&lt;\/version>\n&lt;\/dependency><\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff01\u5982\u679c\u60a8\u9009\u62e9\u4e86\u975e\u9ed8\u8ba4\u5f15\u64ce\uff0c\u9700\u8981\u5728 AutoGenerator \u4e2d \u8bbe\u7f6e\u6a21\u677f\u5f15\u64ce\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AutoGenerator generator = new AutoGenerator();\n\n\/\/ set freemarker engine\ngenerator.setTemplateEngine(new FreemarkerTemplateEngine());\n\n\/\/ set beetl engine\ngenerator.setTemplateEngine(new BeetlTemplateEngine());\n\n\/\/ set custom engine (reference class is your custom engine class)\ngenerator.setTemplateEngine(new CustomTemplateEngine());\n\n\/\/ other config\n...<\/code><\/pre>\n\n\n\n<h3>7.2\u7f16\u5199\u914d\u7f6e<\/h3>\n\n\n\n<p>MyBatis-Plus \u7684\u4ee3\u7801\u751f\u6210\u5668\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u81ea\u5b9a\u4e49\u53c2\u6570\u4f9b\u7528\u6237\u9009\u62e9\uff0c\u80fd\u591f\u6ee1\u8db3\u7edd\u5927\u90e8\u5206\u4eba\u7684\u4f7f\u7528\u9700\u6c42\u3002<\/p>\n\n\n\n<ul><li>\u914d\u7f6e GlobalConfig<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  GlobalConfig globalConfig = new GlobalConfig();\n  globalConfig.setOutputDir(System.getProperty(\"user.dir\") + \"\/src\/main\/java\");\n  globalConfig.setAuthor(\"jobob\");\n  globalConfig.setOpen(false);<\/code><\/pre>\n\n\n\n<ul><li>\u914d\u7f6e DataSourceConfig<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  DataSourceConfig dataSourceConfig = new DataSourceConfig();\n  dataSourceConfig.setUrl(\"jdbc:mysql:\/\/localhost:3306\/ant?useUnicode=true&amp;useSSL=false&amp;characterEncoding=utf8\");\n  dataSourceConfig.setDriverName(\"com.mysql.jdbc.Driver\");\n  dataSourceConfig.setUsername(\"root\");\n  dataSourceConfig.setPassword(\"password\");<\/code><\/pre>\n\n\n\n<h2>7.3\u81ea\u5b9a\u4e49\u6a21\u677f\u5f15\u64ce<\/h2>\n\n\n\n<p>\u8bf7\u7ee7\u627f\u7c7b com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine<\/p>\n\n\n\n<h2>7.4\u81ea\u5b9a\u4e49\u4ee3\u7801\u6a21\u677f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u6307\u5b9a\u81ea\u5b9a\u4e49\u6a21\u677f\u8def\u5f84, \u4f4d\u7f6e\uff1a\/resources\/templates\/entity2.java.ftl(\u6216\u8005\u662f.vm)\n\/\/\u6ce8\u610f\u4e0d\u8981\u5e26\u4e0a.ftl(\u6216\u8005\u662f.vm), \u4f1a\u6839\u636e\u4f7f\u7528\u7684\u6a21\u677f\u5f15\u64ce\u81ea\u52a8\u8bc6\u522b\nTemplateConfig templateConfig = new TemplateConfig()\n    .setEntity(\"templates\/entity2.java\");\n\nAutoGenerator mpg = new AutoGenerator();\n\/\/\u914d\u7f6e\u81ea\u5b9a\u4e49\u6a21\u677f\nmpg.setTemplate(templateConfig);<\/code><\/pre>\n\n\n\n<h2>7.5\u81ea\u5b9a\u4e49\u5c5e\u6027\u6ce8\u5165<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>InjectionConfig injectionConfig = new InjectionConfig() {\n    \/\/\u81ea\u5b9a\u4e49\u5c5e\u6027\u6ce8\u5165:abc\n    \/\/\u5728.ftl(\u6216\u8005\u662f.vm)\u6a21\u677f\u4e2d\uff0c\u901a\u8fc7${cfg.abc}\u83b7\u53d6\u5c5e\u6027\n    @Override\n    public void initMap() {\n        Map&lt;String, Object> map = new HashMap&lt;>();\n        map.put(\"abc\", this.getConfig().getGlobalConfig().getAuthor() + \"-mp\");\n        this.setMap(map);\n    }\n};\nAutoGenerator mpg = new AutoGenerator();\n\/\/\u914d\u7f6e\u81ea\u5b9a\u4e49\u5c5e\u6027\u6ce8\u5165\nmpg.setCfg(injectionConfig);\nentity2.java.ftl\n\u81ea\u5b9a\u4e49\u5c5e\u6027\u6ce8\u5165abc=${cfg.abc}\n\nentity2.java.vm\n\u81ea\u5b9a\u4e49\u5c5e\u6027\u6ce8\u5165abc=$!{cfg.abc}<\/code><\/pre>\n\n\n\n<h2>7.6\u5b57\u6bb5\u5176\u4ed6\u4fe1\u606f\u67e5\u8be2\u6ce8\u5165<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img   class=\"lazyload\" data-src=\"https:\/\/img-blog.csdnimg.cn\/20201206012234298.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTE4NzAwMjI=,size_16,color_FFFFFF,t_70\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"[\u5916\u94fe\u56fe\u7247\u8f6c\u5b58\u5931\u8d25,\u6e90\u7ad9\u53ef\u80fd\u6709\u9632\u76d7\u94fe\u673a\u5236,\u5efa\u8bae\u5c06\u56fe\u7247\u4fdd\u5b58\u4e0b\u6765\u76f4\u63a5\u4e0a\u4f20(img-LVSgwljs-1607188884970)(E:\\\u65b0\u6280\u672f\u5b66\u4e60\\java_study\\mybatis-plus\u5b66\u4e60\\images\\custom-fields.png)]\"\/><\/figure >\n<noscript><img src=\"https:\/\/img-blog.csdnimg.cn\/20201206012234298.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTE4NzAwMjI=,size_16,color_FFFFFF,t_70\" alt=\"[\u5916\u94fe\u56fe\u7247\u8f6c\u5b58\u5931\u8d25,\u6e90\u7ad9\u53ef\u80fd\u6709\u9632\u76d7\u94fe\u673a\u5236,\u5efa\u8bae\u5c06\u56fe\u7247\u4fdd\u5b58\u4e0b\u6765\u76f4\u63a5\u4e0a\u4f20(img-LVSgwljs-1607188884970)(E:\\\u65b0\u6280\u672f\u5b66\u4e60\\java_study\\mybatis-plus\u5b66\u4e60\\images\\custom-fields.png)]\"\/><\/figure><\/noscript>\n\n\n\n<pre class=\"wp-block-code\"><code>new DataSourceConfig().setDbQuery(new MySqlQuery() {\n\n    \/**\n     * \u91cd\u5199\u7236\u7c7b\u9884\u7559\u67e5\u8be2\u81ea\u5b9a\u4e49\u5b57\u6bb5&lt;br>\n     * \u8fd9\u91cc\u67e5\u8be2\u7684 SQL \u5bf9\u5e94\u7236\u7c7b tableFieldsSql \u7684\u67e5\u8be2\u5b57\u6bb5\uff0c\u9ed8\u8ba4\u4e0d\u80fd\u6ee1\u8db3\u4f60\u7684\u9700\u6c42\u8bf7\u91cd\u5199\u5b83&lt;br>\n     * \u6a21\u677f\u4e2d\u8c03\u7528\uff1a  table.fields \u83b7\u53d6\u6240\u6709\u5b57\u6bb5\u4fe1\u606f\uff0c\n     * \u7136\u540e\u5faa\u73af\u5b57\u6bb5\u83b7\u53d6 field.customMap \u4ece MAP \u4e2d\u83b7\u53d6\u6ce8\u5165\u5b57\u6bb5\u5982\u4e0b  NULL \u6216\u8005 PRIVILEGES\n     *\/\n    @Override\n    public String&#91;] fieldCustom() {\n        return new String&#91;]{\"NULL\", \"PRIVILEGES\"};\n    }\n})<\/code><\/pre>\n\n\n\n<h3>7.7\u66f4\u8be6\u7ec6\u7684\u914d\u7f6e\uff1a<a href=\"https:\/\/baomidou.com\/config\/generator-config.html\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/baomidou.com\/config\/generator-config.html<\/a><\/h3>\n\n\n\n<h3>7.8.\u6d4b\u8bd5\u7684\u6e90\u4ee3\u7801\u5df2\u4e0a\u4f20\u5230GitHub\u4e2d\uff1a<a href=\"https:\/\/github.com\/LJF2402901363\/java_study.git\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/github.com\/LJF2402901363\/java_study.git<\/a><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img   class=\"lazyload\" data-src=\"https:\/\/img-blog.csdnimg.cn\/20201205181629733.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTE4NzAwMjI=,size_16,color_FFFFFF,t_70\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/moezx\/cdn@3.0.2\/img\/svg\/loader\/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\"  alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure >\n<noscript><img src=\"https:\/\/img-blog.csdnimg.cn\/20201205181629733.png?x-oss-process=image\/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTE4NzAwMjI=,size_16,color_FFFFFF,t_70\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"\/><\/figure><\/noscript>\n","protected":false},"excerpt":{"rendered":"<p>7.\u4ee3\u7801\u751f\u6210\u5668 AutoGenerator \u662f MyBatis-Plus \u7684\u4ee3\u7801\u751f\u6210\u5668\uff0c\u901a\u8fc7 AutoGenerator \u53ef\u4ee5\u5feb\u901f &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[160,162],"_links":{"self":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/416"}],"collection":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":1,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":417,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions\/417"}],"wp:attachment":[{"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/moyisuiying.com\/index.php\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}