版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangmaohong0717/article/details/82260802
数据库里面表的字段中带有“”_“下划线,我们知道插件默认的是将这些带有下划线的字段默认的变成“优美的驼峰式”的。表是肯定不能动的,实体类的字段也是非常多,改起来非常麻烦,所以就研究了下面这种依靠代码来实现的方式。
修改配置文件:
<?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="E:\mysql-connector-java-5.1.29.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://172.16.14.40:3306/zhu"
userId="zhu" password="zhu" />
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL
和 NUMERIC 类型解析为java.math.BigDecimal -->
</javaTypeResolver>
<javaModelGenerator targetPackage="com.tt.domain"
targetProject="MybatisT/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.tt.domain"
targetProject="MybatisT/src/main/resources">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<table tableName="zlpg_value" enableSelectByExample="false"
enableDeleteByExample="false" enableCountByExample="false"
selectByExampleQueryId="true" enableUpdateByExample="false">
<property name="useActualColumnNames" value="true"/>
<!-- <generatedKey column="ID" sqlStatement="oracle" identity="true" /> -->
</table>
</context>
</generatorConfiguration>
<property name="useActualColumnNames" value="true"/>