在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&characterEncoding=utf-8&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>