{"id":4042,"date":"2024-08-21T20:02:15","date_gmt":"2024-08-21T12:02:15","guid":{"rendered":"https:\/\/qaqaq.top\/?p=4042"},"modified":"2024-08-21T20:19:57","modified_gmt":"2024-08-21T12:19:57","slug":"mybatis-plus%e4%bb%a3%e7%a0%81%e7%94%9f%e6%88%90%e5%99%a8","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=4042","title":{"rendered":"MyBatis-Plus\u4ee3\u7801\u751f\u6210\u5668"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5f15\u5165\u4f9d\u8d56<\/h2>\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.5.7&lt;\/version>\n        &lt;\/dependency>\n        &lt;dependency>\n            &lt;groupId>org.freemarker&lt;\/groupId>\n            &lt;artifactId>freemarker&lt;\/artifactId>\n            &lt;version>2.3.33&lt;\/version>\n        &lt;\/dependency><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5feb\u901f\u751f\u6210<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>public class FastAutoGeneratorTest {\n\n    public static void main(String&#91;] args) {\n\n        String url = \"jdbc:mysql:\/\/127.0.0.1:3306\/study?serverTimezone=GMT%2B8&amp;characterEncoding=utf-8&amp;useSSL=false\";\n        String username = \"root\";\n        String password = \"\";\n\n        FastAutoGenerator.create(url, username, password)\n                .globalConfig(builder -> {\n                    builder.author(\"qaqaq\") \/\/ \u8bbe\u7f6e\u4f5c\u8005\n                            .enableSwagger() \/\/ \u5f00\u542f swagger \u6a21\u5f0f\n                            .outputDir(\"D:\/\/Java\/\/Code\/\/study\/\/mybatisplus-create\"); \/\/ \u6307\u5b9a\u8f93\u51fa\u76ee\u5f55\n                })\n                .dataSourceConfig(builder ->\n                        builder.typeConvertHandler((globalConfig, typeRegistry, metaInfo) -> {\n                            int typeCode = metaInfo.getJdbcType().TYPE_CODE;\n                            if (typeCode == Types.SMALLINT) {\n                                \/\/ \u81ea\u5b9a\u4e49\u7c7b\u578b\u8f6c\u6362\n                                return DbColumnType.INTEGER;\n                            }\n                            return typeRegistry.getColumnType(metaInfo);\n                        })\n                )\n                .packageConfig(builder ->\n                        builder.parent(\"top.qaqaq\") \/\/ \u8bbe\u7f6e\u7236\u5305\u540d\n                                .moduleName(\"mybatisplus\") \/\/ \u8bbe\u7f6e\u7236\u5305\u6a21\u5757\u540d\n                                .pathInfo(Collections.singletonMap(OutputFile.xml, \"D:\/\/Java\/\/Code\/\/study\/\/mybatisplus-create\")) \/\/ \u8bbe\u7f6emapperXml\u751f\u6210\u8def\u5f84\n                )\n                .strategyConfig(builder ->\n                        builder.addInclude(\"t_user\") \/\/ \u8bbe\u7f6e\u9700\u8981\u751f\u6210\u7684\u8868\u540d\n                                .addTablePrefix(\"t_\", \"c_\") \/\/ \u8bbe\u7f6e\u8fc7\u6ee4\u8868\u524d\u7f00\n                )\n                .templateEngine(new FreemarkerTemplateEngine()) \/\/ \u4f7f\u7528Freemarker\u5f15\u64ce\u6a21\u677f\uff0c\u9ed8\u8ba4\u7684\u662fVelocity\u5f15\u64ce\u6a21\u677f\n                .execute();\n\n    }\n\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u5165\u4f9d\u8d56 \u5feb\u901f\u751f\u6210<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[183],"class_list":["post-4042","post","type-post","status-publish","format-standard","hentry","category-mybatisplus-","tag-mybatisplus"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/4042"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4042"}],"version-history":[{"count":3,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/4042\/revisions"}],"predecessor-version":[{"id":4045,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/4042\/revisions\/4045"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}