MyBatis Generator 移除字段前綴


在table標簽內添加

<columnRenamingRule searchString="wrc_" replaceString=""/>

<?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.40.jar"  />

    <context id="my" targetRuntime="MyBatis3">

        <commentGenerator>
            <property name="suppressAllComments" value="true" /><!-- 是否取消注釋 -->
            <property name="suppressDate" value="true" /> <!-- 是否生成注釋代時間戳 -->
        </commentGenerator>
        <!-- 數據庫連接信息 -->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://127.0.0.1:3306/reptile?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true" userId="root"
                        password="123456" />

        <!-- 只有一個屬於forceBigDecimals,默認false。 如果字段精確超過0,生成BigDecimal 如果字段精確是0,總長度10-18生成Long;如果字段精確是0,
            總長5-9生成Integer; 如果字段精確是0,總長小於5生成Short; 如果forceBigDecimals為true,統一生成BigDecimal -->
        <javaTypeResolver>
            <!-- 是否使用bigDecimal, false可自動轉化以下類型(Long, Integer, Short, etc.) -->
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>

        <!--生成Model.java文件 -->
        <javaModelGenerator targetPackage="com.reptile.entity"
                            targetProject="src/main/java">
            <!-- enableSubPackages:是否讓schema作為包的后綴 -->
            <property name="enableSubPackages" value="false" />
            <!-- 是否針對string類型的字段在set的時候進行trim調用 -->
            <property name="trimStrings" value="true" />
        </javaModelGenerator>


        <!-- 生成Mapper.xml文件 -->
        <sqlMapGenerator targetPackage="mapper"
                         targetProject="src/main/resources">
            <!-- enableSubPackages:是否讓schema作為包的后綴 -->
            <property name="enableSubPackages" value="false" />
        </sqlMapGenerator>

        <!-- 生成Mapper.java文件,即dao層 -->
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.reptile.mapper" targetProject="src/main/java">
            <property name="enableSubPackages" value="false" />  
        </javaClientGenerator>


        <!-- 待生成的數據庫中的表名,生成一個表對應的Java和xml文件就需要配置一段 -->
        <table tableName="tb_weekly" domainObjectName="Weekly"
               enableCountByExample="false" enableUpdateByExample="false"
               enableDeleteByExample="false" enableSelectByExample="false"
               selectByExampleQueryId="false">
            <!--移除字段前綴-->
            <columnRenamingRule searchString="wrc_" replaceString=""/>
        </table>



    </context>

</generatorConfiguration>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM