zoukankan      html  css  js  c++  java
  • 总结一下java如何进行逆向工程

    第一步在百度搜索Mybatis generator 在官网进行搜索 http://www.mybatis.org/generator/ 并且找到

     第二步导入jar包点击See the XML Configuration File Reference page for an example of a configuration file.建立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="D:\\jar\\mybatis-generator-core-1.3.5.jar" />
      
    <!--  数据源信息-->
      <context id="DB2Tables" targetRuntime="MyBatis3">
      <!--禁止所有注释  -->
      <commentGenerator>
      <property name="suppressAllComments" value="true" />
    </commentGenerator> 
    
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://localhost:3306/mybatis"
            userId="root"
            password="root">
        </jdbcConnection>
    
        <javaTypeResolver >
          <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
    <!-- 生产实体类的位置 -->
        <javaModelGenerator targetPackage="com.zhiyou100.xth.bean" targetProject="./src">
          <property name="enableSubPackages" value="true" />
          <property name="trimStrings" value="true" />
        </javaModelGenerator>
    <!-- 生产映射文件所在位置 -->
        <sqlMapGenerator targetPackage="com.zhiyou100.xth.mapper"  targetProject="./resources">
          <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>
    <!-- 生产dao文件的所在位置 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.zhiyou100.xth.dao"  targetProject="./src">
          <property name="enableSubPackages" value="true" />
        </javaClientGenerator>
       <!--表  
      schema 该表所在的数据库
      domainObjectName 实体类名
       -->
        <table schema="mybatis" tableName="users" domainObjectName="Users"
        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>

    第三步运行

    第四步

     点击

    第五步 

     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);

    在主函数里面导包运行

           

  • 相关阅读:
    批处理
    使用T-SQL语句更新数据、删除
    使用T-SQL语句一次性插入另一张表的数据
    使用T-SQL语句插入数据
    CSS色调旋转滤镜
    初探Lerna
    基层管理人员的部分思考 --读《大秦帝国》有感
    (转)React学习笔记(干货满满)
    git常用命令(转)
    个人JS体系整理(三)
  • 原文地址:https://www.cnblogs.com/meifanghua/p/11437506.html
Copyright © 2011-2022 走看看