Mybatis Generator作为应用最为广泛的代码生产插件,经过查阅资料,整理了以下比较完整配置详解
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <?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>
<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>
|