zoukankan      html  css  js  c++  java
  • 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);
    
        }
    
    }
  • 相关阅读:
    windows7修改双系统启动项名称、先后顺序、等待时间
    windows初始化后做了哪些事情
    我的wordpress插件总结
    分析MySQL慢日志(转)
    在Java中使用Memcached(转)
    memcached应用场景(转)
    memcached简介(转)
    Linux下memcache的安装和启动(转)
    列式数据库
    Android测试(一):在Android中测试App
  • 原文地址:https://www.cnblogs.com/accc111/p/11449204.html
Copyright © 2011-2022 走看看