zoukankan      html  css  js  c++  java
  • 逆向工程 mybatis generator

    1.搜索mybatis generator

    2.快速入门

    3.下载Jar包

     4.复制配置代码

    <?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>
      <classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" />
    
      <context id="DB2Tables" targetRuntime="MyBatis3">
        <jdbcConnection driverClass="COM.ibm.db2.jdbc.app.DB2Driver"
            connectionURL="jdbc:db2:TEST"
            userId="db2admin"
            password="db2admin">
        </jdbcConnection>
    
        <javaTypeResolver >
          <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
    
        <javaModelGenerator targetPackage="test.model" targetProject="MBGTestProjectsrc">
          <property name="enableSubPackages" value="true" />
          <property name="trimStrings" value="true" />
        </javaModelGenerator>
    
        <sqlMapGenerator targetPackage="test.xml"  targetProject="MBGTestProjectsrc">
          <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>
    
        <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao"  targetProject="MBGTestProjectsrc">
          <property name="enableSubPackages" value="true" />
        </javaClientGenerator>
    
        <table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" >
          <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>

     5.运行generator文件

     

       List<String> warnings = new ArrayList<String>();
       boolean overwrite = true;
       File configFile = new File("generatorConfig.xml");
       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);
    导包快捷键CTRL+shift+o
  • 相关阅读:
    Finder 的分栏显示模式宽度调整
    IBAction作用相当于void,NSLog(@"被调用的方法名是%s",__func__);
    Trapping Rain Water
    Binary Tree Preorder Traversal
    Valid Parentheses
    Reverse Words in a String | LeetCode OJ | C++
    Gas Station|leetcode 贪心
    两个字符串“相等”
    Binary Tree Zigzag Level Order Traversal
    Add Binary
  • 原文地址:https://www.cnblogs.com/sh-0131/p/11437226.html
Copyright © 2011-2022 走看看