Mybatis Generator配置详解

原文地址

原文地址

(感谢大佬)

官网地址

依赖包下载




<generatorConfiguration>

 
 
  

<context id="mysql" defaultModelType="hierarchical" targetRuntime="MyBatis3Simple" >

    
    <property name="autoDelimitKeywords" value="false"/>
    
    <property name="javaFileEncoding" value="UTF-8"/>
    
    <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
    
    <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
    
    
    <property name="beginningDelimiter" value="`"/>
    <property name="endingDelimiter" value="`"/>
    
    
    <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql:///pss" userId="root" password="admin">
        
    jdbcConnection>
    
    
    <javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
        
        <property name="forceBigDecimals" value="false"/>
    javaTypeResolver>
    
    
    
    <javaModelGenerator targetPackage="com._520it.mybatis.domain" targetProject="src/main/java">
        
        <property name="constructorBased" value="false"/>
        
        
        <property name="enableSubPackages" value="true"/>
        
        
        <property name="immutable" value="false"/>
        
        
        <property name="rootClass" value="com._520it.mybatis.domain.BaseDomain"/>
        
        
        <property name="trimStrings" value="true"/>
    javaModelGenerator>
    
    
    
    <sqlMapGenerator targetPackage="com._520it.mybatis.mapper" targetProject="src/main/resources">
        
        <property name="enableSubPackages" value="true"/>
    sqlMapGenerator>
    
    
    
    <javaClientGenerator targetPackage="com._520it.mybatis.mapper" type="ANNOTATEDMAPPER" targetProject="src/main/java">
        
        <property name="enableSubPackages" value="true"/>
        
        
    javaClientGenerator>
    
    
    <table tableName="userinfo" >
        
        
        <property name="constructorBased" value="false"/>
        
        
        <property name="ignoreQualifiersAtRuntime" value="false"/>
        
        
        <property name="immutable" value="false"/>
        
        
        <property name="modelOnly" value="false"/>
        
        
         
        
        
        
        
        
        
        
        
        
        <property name="selectAllOrderByClause" value="age desc,username asc"/>
        
        
        <property name="useActualColumnNames" value="false"/>
        
        
        
        
        
         
         
         
         <columnOverride column="username">
            
            <property name="property" value="userName"/>
            
            
             
            
             
            
            
            
         columnOverride>
         
         
    table>
    
context>

generatorConfiguration>

其他规则



<classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" />


<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>


<table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" >
  <columnRenamingRule searchString="^CUST_" replaceString="" />
  ..
table>




<commentGenerator>
  <property name="suppressDate" value="true" />
commentGenerator>

    <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>

    <table schema="DB2ADMIN" tableName="ALLTYPES" domainObjectName="Customer" >
      <ignoreColumn column="FRED" />
      ..
    table>


你可能感兴趣的:(mybatis,mybatis,generator)