Mybatis外掛之自動生成不使用預設的駝峰式
阿新 • • 發佈:2018-11-29
資料庫裡面表的欄位中帶有“”_“下劃線,我們知道外掛預設的是將這些帶有下劃線的欄位預設的變成“優美的駝峰式”的。表是肯定不能動的,實體類的欄位也是非常多,改起來非常麻煩,所以就研究了下面這種依靠程式碼來實現的方式。
修改配置檔案:
<?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"/>