逆向生成mapper

genreator.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>
    <context id="promotion" targetRuntime="Mybatis3">

        <!-- defaultModelType="hierarchical" -->
        <property name="javaFileEncoding" value="UTF-8"/>
        <property name="suppressTypeWarnings" value="true"/>

        <plugin type="org.mybatis.generator.plugins.RowBoundsPlugin"/>


        <plugin type="org.mybatis.generator.plugins.MapperConfigPlugin">
            <!--<property name="fileName" value="mapper-config.xml"/>-->
            <property name="fileName" value="mybatis-config.xml"/>
            <property name="targetPackage" value="com.xhh.test.db.mapper"/>
            <property name="targetProject"
                      value="MAVEN"/>
        </plugin>
        <plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin">
            <property name="searchString" value="Example$"/>
            <property name="replaceString" value="Criteria"/>
        </plugin>

        <!-- 注释 -->
        <commentGenerator>
            <property name="suppressDate" value="true"/> <!-- 是否生成注释代时间戳 -->
            <property name="addRemarkComments" value="false"/>
        </commentGenerator>

        <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
                        connectionURL="jdbc:oracle:thin:@172.20.201.138:1521:SRMUSG" userId="srmusg"
                        password="prod9999"/>

        <!-- 类型转换 -->
        <javaTypeResolver>
            <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>

        <!-- 生成实体类地址 -->
        <javaModelGenerator targetPackage="com.dzh.test.db.entity"
                            targetProject="src/main/java">
<!--            &lt;!&ndash; 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model,-->
<!--            true:com.oop.eksp.user.model.[schemaName] &ndash;&gt;-->
            <property name="enableSubPackages" value="true"/>
<!--            &lt;!&ndash; 是否针对string类型的字段在set的时候进行trim调用 &ndash;&gt;-->
            <property name="trimStrings" value="false"/>
        </javaModelGenerator>

        <!-- 生成mapxml文件 -->
        <!--targetProject="MAVEN">-->
        <sqlMapGenerator targetPackage="mapper/oracle"
                         targetProject="src/main/resources">
            <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>

        <!-- 生成mapxml对应client,也就是接口dao -->
        <javaClientGenerator targetPackage="com.dzh.test.db.mapper.oracle"
                             targetProject="src/main/java" type="XMLMAPPER">
<!--            &lt;!&ndash; 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] &ndash;&gt;-->
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <table tableName="T_USER"
               enableSelectByPrimaryKey="true"
               enableSelectByExample="false"
               enableUpdateByPrimaryKey="true"
               enableUpdateByExample="false"
               enableDeleteByPrimaryKey="true"
               enableDeleteByExample="false"
               enableCountByExample="false"
               selectByPrimaryKeyQueryId="true"
               selectByExampleQueryId="false"
               enableInsert="true">
            <property name="useActualColumnNames" value="false"/>
        </table>

    </context>
</generatorConfiguration>

使用idea的逆向生成插件工具:

逆向生成mapper

连接需要逆向生成的数据库

找到需要逆向生成的表右键

逆向生成mapper

选择第一个mybatis-generator

不知道的就选择默认的

点击OK

逆向生成完成。

上一篇:IDEA查看某个类的继承及接口实现关系的方法


下一篇:python-plotly