MyBatis Generator配置文件翻译
From: https://www.cnblogs.com/GaiDynasty/p/4088531.html
<classPathEntry>
驅(qū)動(dòng)文件指定配置項(xiàng)
<classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" /><columnOverride>
將數(shù)據(jù)庫(kù)中的字段重命名為實(shí)體類(lèi)的屬性
column?數(shù)據(jù)庫(kù)中字段名
property?POJO屬性名
javaType POJO類(lèi)型
jdbcType?數(shù)據(jù)庫(kù)字段類(lèi)型
<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><property name="useActualColumnNames" value="true"/><generatedKey column="ID" sqlStatement="DB2" identity="true" /><columnOverride column="DATE_FIELD" property="startDate" /><ignoreColumn column="FRED" /><columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /></table><columnRenamingRule>
按規(guī)則將數(shù)據(jù)庫(kù)中的字段重命名為實(shí)體類(lèi)的屬性
<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><columnRenamingRule searchString="^CUST_" replaceString="" />.. </table><commentGenerator>
代碼上面的注釋規(guī)則
子屬性:property
porperties:
suppressAllComments? false時(shí)打開(kāi)注釋,true時(shí)關(guān)閉注釋
suppressDate? false時(shí)打開(kāi)時(shí)間標(biāo)志,true時(shí)關(guān)閉...真是反人類(lèi)啊
<commentGenerator><property name="suppressDate" value="true" /> </commentGenerator><context>
這個(gè)實(shí)在不知道怎么解釋,反正就是大環(huán)境
targetRuntime?可選項(xiàng),可填值為MyBatis3,MyBatis3Simple(默認(rèn)的),Ibatis2Java2,Ibatis2Java5
<context id="DB2Tables" targetRuntime="MyBatis3">... </context><generatedKey>
指定自增加以及Id
column?字段
sqlStatement?數(shù)據(jù)庫(kù)語(yǔ)句,可以為MySql,DB2,SqlServer,SyBase等http://mybatis.github.io/generator/configreference/generatedKey.html
identity?true為id,false不為id
<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><property name="useActualColumnNames" value="true"/><generatedKey column="ID" sqlStatement="DB2" identity="true" /><columnOverride column="DATE_FIELD" property="startDate" /><ignoreColumn column="FRED" /><columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /></table><ignoreColumn>
忽略字段
column?字段名
<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" ><ignoreColumn column="FRED" />..</table><javaClientGenerator>
Mapper生成配置
type?XMLMAPPER配置文件方式,ANNOTATEDMAPPER注解方式
http://mybatis.github.io/generator/configreference/javaClientGenerator.html
<javaClientGenerator type="XMLMAPPER"targetPackage="dao.mapper" targetProject="app"><property name="enableSubPackages" value="true" /></javaClientGenerator><javaModelGenerator>
實(shí)體類(lèi)生成配置
http://mybatis.github.io/generator/configreference/javaModelGenerator.html
<javaModelGenerator targetPackage="domain"targetProject="app"><property name="enableSubPackages" value="true" /><property name="trimStrings" value="false" /></javaModelGenerator><javaTypeResolver>
mybatis里專(zhuān)門(mén)用來(lái)處理NUMERIC和DECIMAL類(lèi)型的策略
<javaTypeResolver><property name="forceBigDecimals" value="true" /> </javaTypeResolver><jdbcConnection>
jdbc配置,不解釋了哈
<jdbcConnection driverClass="COM.ibm.db2.jdbc.app.DB2Driver"connectionURL="jdbc:db2:MBGTEST"userId="db2admin"password="db2admin"> </jdbcConnection><sqlMapGenerator>
生成sql語(yǔ)句的xml文件
在mybatis2里是必須的,在mybatis3中,只有用XML方式的時(shí)候才是需要的。
<sqlMapGenerator targetPackage="test.model"targetProject="\MyProject\src"><property name="enableSubPackages" value="true" /> </sqlMapGenerator>總結(jié)
以上是生活随笔為你收集整理的MyBatis Generator配置文件翻译的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c语言开根函数不用math,c语言开平方
- 下一篇: 使用composer下载依赖包下载失败的