generator工具类代码逆向工程生成器。

generator代码逆向工程生成器。

自己现在在用的一个逆向工具,看到CSDN好多要收费,还希望能帮到有用的人。复制过去可以直接拿去用,稍微修改一下

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>
<!--  <classPathEntry location="D:\mysql-connector-java-5.1.0-bin.jar" />-->
  <context id="Mysql2Tables" targetRuntime="MyBatis3">
    <commentGenerator>
      <property name="suppressDate" value="true"></property>
      <property name="suppressAllComments" value="true"></property>
    </commentGenerator>

   <jdbcConnection driverClass="com.mysql.jdbc.Driver"
        connectionURL=""//数据库的路径,下面是账号密码
        userId=""
        password="">
    </jdbcConnection>

    <javaTypeResolver >
      <property name="forceBigDecimals" value="false" />
    </javaTypeResolver>
    <!--实体类文件生成-->
    <javaModelGenerator targetPackage="com.sharainy.pojo" targetProject="src/main/java">
      <property name="enableSubPackages" value="true" />
      <property name="trimStrings" value="true" />
    </javaModelGenerator>
      <!--mapper接口生成-->
    <sqlMapGenerator targetPackage="com.sharainy.mapper"  targetProject="src/main/java">
      <property name="enableSubPackages" value="true" />
    </sqlMapGenerator>
      <!--mapper.xml生成-->
    <javaClientGenerator type="XMLMAPPER" targetPackage="com.sharainy.mapper"  targetProject="src/main/java">
      <property name="enableSubPackages" value="true" />
    </javaClientGenerator>

      <!--数据库需要生成的表,只需要修改tabalName对应数据库表-->
      <table  tableName="geteway" enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="true" selectByExampleQueryId="false">
      </table>
     <!-- <table  tableName="district" enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="true" selectByExampleQueryId="false">
      </table>

      <table  tableName="street" enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="true" selectByExampleQueryId="false">
      </table>

      <table  tableName="type" enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="true" selectByExampleQueryId="false">
      </table>

      <table  tableName="house" enableCountByExample="false" enableUpdateByExample="false"
              enableDeleteByExample="false" enableSelectByExample="true" selectByExampleQueryId="false">
      </table>
-->
  </context>

启动的Util

public static void main(String[] args) {
        try {
            System.out.println("start generator ...");
            List<String> warnings = new ArrayList<String>();
            boolean overwrite = true;
            File configFile = new File(MybatisGeneratorUtil.class.getResource("/generator.xml").getFile());//这里写你的generator.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);
            System.out.println("干啥啥不行,用起工具第一名!");
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XMLParserException e) {
            e.printStackTrace();
        } catch (InvalidConfigurationException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

Alt

一起加油!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值