mybatis逆向工程generatorConfiguration详细配置

时间:2021-01-14 21:22:41
<?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> <!-- 指定数据连接驱动jar地址 -->
<classPathEntry
location="C:/m2/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar" /> <!-- 一个数据库一个context -->
<context id="context">
<!-- 注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" /><!-- 是否取消注释 -->
<property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳 -->
</commentGenerator> <!-- jdbc连接 -->
<jdbcConnection
connectionURL=""
driverClass="com.mysql.jdbc.Driver" password=""
userId="" /> <!-- 类型转换 -->
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<property name="forceBigDecimals" value="false" />
</javaTypeResolver> <!-- 生成实体类的包名和位置 注意targetProject的值为实体类放在工程中具体位置的相对路径, -->
<javaModelGenerator targetPackage="com.alipayeco.medicalinscore.dal.entity"
targetProject="mybatis-generator-tool\\src\main\java">
<!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
<property name="enableSubPackages" value="true" />
<!-- 是否针对string类型的字段在set的时候进行trim调用 -->
<property name="trimStrings" value="true" />
</javaModelGenerator> <!-- 生成的SQLMapper映射文件包名和位置 -->
<sqlMapGenerator targetPackage="com.alipayeco.medicalinscore.dal.mapper"
targetProject="mybatis-generator-tool\\src\main\resources">
<!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
<property name="enableSubPackages" value="true" />
</sqlMapGenerator> <!-- 生成DAO的包名和位置,这里配置将生成的dao类放在me.gacl.dao这个包下 -->
<javaClientGenerator targetPackage="com.alipayeco.medicalinscore.dal.mapper"
targetProject="mybatis-generator-tool\\src\main\java" type="XMLMAPPER">
<!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
<property name="enableSubPackages" value="true" />
</javaClientGenerator> <!-- 配置表信息 -->
<!-- schema即为数据库名 tableName为对应的数据库表 domainObjectName是要生成的实体类 enable*ByExample
是否生成 example类 -->
<!-- 更改tableName和domainObjectName就可以 -->
<table schema="bridge-db-test" tableName="account_si_income_info" mapperName="AccountSiIncomeInfoMapper"
domainObjectName="AccountSiIncomeInfoDO" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false">
<!-- 下面子属性是保持数据库与实体类字段名一致性 -->
<property name="useActualColumnNames" value="true"/>
</table>
</context>
</generatorConfiguration>

注: jdbcType为tinyint类型转换成javaType会变成byte类型