• Mybatis-逆向工程generator


    导包

    mybatis-generator-core-1.3.5.jar

    配置generator.xml

    <?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>
    <!--从本地获取数据库jar包--> <classPathEntry location="C://Users/pc/Desktop/第一次项目/mysql-connector-java-5.1.47-bin.jar"/> <context id="DB2Tables" targetRuntime="MyBatis3"> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/mybatis?useSSL=false" userId="root" password="123456"> </jdbcConnection> <javaTypeResolver > <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!--构建实体类--> <javaModelGenerator targetPackage="com.zhiyou100.xf.bean" targetProject="./src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!--构建sql映射--> <sqlMapGenerator targetPackage="com.zhiyou100.xf.mapper" targetProject="./resources"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!--构建接口调用--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.zhiyou100.xf.dao" targetProject="./src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!--选择表生成实体类,false可生成简单sql--> <table schema="DB2ADMIN" tableName="users" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"> <property name="useActualColumnNames" value="true"/> <generatedKey column="ID" sqlStatement="DB2" identity="true" /> <columnOverride column="DATE_FIELD" property="startDate" /> <ignoreColumn column="FRED" /> <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /> </table> </context> </generatorConfiguration>

    执行

    public class Test {
    
        public static void main(String[] args) throws SQLException, IOException, InterruptedException, XMLParserException, InvalidConfigurationException {
            List<String> warnings = new ArrayList<String>();
               boolean overwrite = true;
               File configFile = new File("generator.xml");//配置的generator文件
               ConfigurationParser cp = new ConfigurationParser(warnings);
               Configuration config = cp.parseConfiguration(configFile);
               DefaultShellCallback callback = new DefaultShellCallback(overwrite);
               MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
               myBatisGenerator.generate(null);
    
        }
    
    }
  • 相关阅读:
    jQuery 回到顶部
    c# 获取客户端ip
    JS 新浪API获取IP归属地
    c#抓取网站数据
    ECLIPSE最常用快捷键排名
    BinarySearchTree示例——C++模板实现
    SICP 找零钱问题背后的思考
    关于解引用*和箭头操作符->的重载
    traits技法小计
    最大和子序列问题
  • 原文地址:https://www.cnblogs.com/accc111/p/11449204.html
Copyright © 2020-2023  润新知