zoukankan      html  css  js  c++  java
  • mybatis 自动生成mapper文件

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
            "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
    <generatorConfiguration>
        <context id="mysqlTables" targetRuntime="MyBatis3">
    
            <commentGenerator>
                <!-- 是否去除自动生成的注释 true:是 : false:否 -->
                <property name="suppressAllComments" value="true" />
            </commentGenerator>
    
            <!-- 数据库连接 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                            connectionURL="jdbc:mysql://127.0.0.1:3306/test?characterEncoding=UTF-8"
                            userId="root"
                            password="#####"/>
            <!--指定生成的类型为java类型,避免数据库中number等类型字段 -->
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
    
            <!--自动生成的实体的存放包路径-->
            <javaModelGenerator targetPackage="com.pojo" targetProject="d:/">
                <property name="enableSubPackages" value="true"/>
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
    
            <!--自动生成的*Mapper.xml文件存放路径 -->
            <sqlMapGenerator targetPackage="mappers" targetProject="d:/">
                <property name="enableSubPackages" value="true"/>
            </sqlMapGenerator>
            <!--自动生成的*Mapper.java存放路径 -->
    <!--         <javaClientGenerator type="XMLMAPPER" targetPackage="com.mapper" targetProject="src/main/java">-->
    <!--             <property name="enableSubPackages" value="true"/>-->
    <!--         </javaClientGenerator>-->
    
            <table tableName="Crj_Apply_Journey" domainObjectName="CrjApplyJourney" enableCountByExample="false" enableUpdateByExample="false"
                   enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
            </table>
    
    
        </context>
    
    
    
    
    
    
    <!--        <table tableName="crj_cabinet_type" domainObjectName="CrjCabinetType" enableCountByExample="false" enableUpdateByExample="false"-->
    <!--               enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
    <!--        </table>-->
    
    <!--         <table tableName="crj_permission" domainObjectName="CrjPermission" enableCountByExample="false" enableUpdateByExample="false"-->
    <!--               enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
    <!--        </table>-->
    <!--        <table tableName="crj_certificate" domainObjectName="CrjCertificate" enableCountByExample="false" enableUpdateByExample="false"-->
    <!--               enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
    <!--        </table>-->
    <!--        <table tableName="crj_department" domainObjectName="CrjDepartment" enableCountByExample="false" enableUpdateByExample="false"-->
    <!--               enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
    <!--        </table>-->
    <!--        <table tableName="crj_role" domainObjectName="CrjRole" enableCountByExample="false" enableUpdateByExample="false"-->
    <!--               enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">-->
    <!--        </table>-->
    
    
    </generatorConfiguration>

     

    package com.util;
    
    import org.mybatis.generator.api.MyBatisGenerator;
    import org.mybatis.generator.config.Configuration;
    import org.mybatis.generator.config.xml.ConfigurationParser;
    import org.mybatis.generator.internal.DefaultShellCallback;
    
    import java.io.File;
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * 描述:
     * <p>
     * author caoxiaoyang
     * date 2021-04-27
     * version
     */
    public class GenUtils {
        public static void main(String[] args) {
            try {
                List<String> warnings = new ArrayList<String>();
                boolean overwrite = true;
                String genCfg = "generatorConfig.xml";
                //D:javasrcmain
    esourcesgeneratorConfig.xml
                File configFile = new File("D:\java\\main\resources\generatorConfig.xml");
                ConfigurationParser cp = new ConfigurationParser(warnings);
                Configuration config = null;
                config = cp.parseConfiguration(configFile);
                DefaultShellCallback callback = new DefaultShellCallback(overwrite);
                MyBatisGenerator myBatisGenerator = null;
                myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
                myBatisGenerator.generate(null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

      

    姓名:曹晓阳 联系方式:1076675163@qq.com
  • 相关阅读:
    JAVA课程设计+五子棋游戏
    201521123059 《Java程序设计》第十四周学习总结
    201521123059 《Java程序设计》第十三周学习总结
    软工个人总结
    alpha阶段个人总结
    centos 下构建lamp环境
    软工15作业3——案例分析
    结对编程
    201521123058 软工阅读第二次作业
    软工阅读作业1(201521123058 李绍乐)
  • 原文地址:https://www.cnblogs.com/CAOXIAOYANG/p/14710039.html
Copyright © 2011-2022 走看看