mybatis数据库逆向工程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38262266/article/details/81001538

mybatis数据库逆向工程

所需jar包及配置文件均在我的下载中,请自行下载
generatorConfigure.xml进行修改
1、修改数据名称以及密码
2、填写java文件生成所在包名称(com.rr.model等)
3、填写数据库表名以及生成类名
<?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="mysql-connector-java-5.1.39-bin.jar"/> -->
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!---->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/books" userId="root" password="root">
        </jdbcConnection>
        <!-- falseJDBC DECIMAL  NUMERIC  Integer trueJDBC DECIMAL 
             NUMERIC java.math.BigDecimal -->
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <!--Model-->
        <javaModelGenerator targetPackage="com.rr.model" targetProject="src">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!---->
        <sqlMapGenerator targetPackage="com.rr.mapping" targetProject="src">
            <!-- enableSubPackages:schema -->
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <!--Dao-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.rr.dao" targetProject="src">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <!---->
        <table tableName="userinfo" domainObjectName="UserInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        <table tableName="books" domainObjectName="Books" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        <table tableName="items" domainObjectName="OrderItem" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
        <table tableName="orders" domainObjectName="Orders" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
    </context>
</generatorConfiguration>
修改完执行java文件即可

猜你喜欢

转载自blog.csdn.net/qq_38262266/article/details/81001538