|
| 1 | +1、增加了获取sqlServer数据库字段注释的功能(官网给出的解释是JDBC不支持获取sqlServer字段注释)。 |
| 2 | +2、扩展生成Bo,table里添加boObjectName属性,对应的XML配置如下: |
| 3 | +<javaBoGeneratortargetPackage="com.btjf.business.authentication.custcertification.Bo" |
| 4 | + targetProject="Java-generator-core/src/main/java"> |
| 5 | + <propertyname="enableSubPackages" value="true" /> |
| 6 | + <propertyname="trimStrings" value="true" /> |
| 7 | +</javaBoGenerator> |
| 8 | +3、(1)table里增加了 |
| 9 | +enableInsertSelective |
| 10 | +enableUpdateByExampleSelective属性,其默认值为true; |
| 11 | +(2)对应的enableUpdateByExample |
| 12 | +enableUpdateByPrimaryKey |
| 13 | +enableInsert默认改成了false ; |
| 14 | +(3)新增enableSelectAll |
| 15 | +enableSelectNotDele |
| 16 | +enableSelectNotDeleteByPrimaryKey属性,默认为false; |
| 17 | +对应的则在Mapper中添加了相应的方法。 |
| 18 | +4、结合freemarker和XML生成了简单的Service和domain,对应的XML配置如下: |
| 19 | +<javaServiceGenerator targetPackage="com.btjf.business.authentication.custcertification.service" |
| 20 | + targetProject="java-generator-core/src/main/java"> |
| 21 | + <propertyname="enableSubPackages" value="true" /> |
| 22 | +</javaServiceGenerator> |
| 23 | +<javaDomainGenerator targetPackage="com.btjf.business.authentication.custcertification.domain" |
| 24 | + targetProject="java-generator-core/src/main/java"> |
| 25 | +</javaDomainGenerator> |
| 26 | +5、 注意:javaBoGenerator、javaServiceGenerator均为可选不进行配置,javaDomainGenerator和javaServiceGenerator成对出现(要么都配置,要么都不配置) |
| 27 | + |
| 28 | +6、附上整个的generatorConfig.xml,所有的均以t_member表为例的。 |
| 29 | +[html] view plain copy |
| 30 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 31 | + |
| 32 | +<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > |
| 33 | +<generatorConfiguration> |
| 34 | + <classPathEntry location="F:/tools/libs/com/microsoft/sqlserver/sqljdbc4/6.0/sqljdbc4-6.0.jar" /> |
| 35 | + <context id="beitaijinfu" targetRuntime="MyBatis3"> |
| 36 | + <property name="javaFileEncoding" value="UTF-8"/> |
| 37 | + <property name="mergeable" value="true" /> |
| 38 | + <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" /> |
| 39 | + <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin"></plugin> |
| 40 | + <plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin> |
| 41 | + <commentGenerator type="org.mybatis.generator.internal.DefaultCommentGenerator"> |
| 42 | + <property name="suppressDate" value="true" /> |
| 43 | + <property name="addRemarkComments" value="true" /> |
| 44 | + </commentGenerator> |
| 45 | + <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver" connectionURL="" |
| 46 | + userId="" password="" /> |
| 47 | + <javaTypeResolver> |
| 48 | + <property name="forceBigDecimals" value="false"/> |
| 49 | + </javaTypeResolver> |
| 50 | + |
| 51 | + <!--<javaBoGenerator targetPackage="com.btjf.business.authentication.custcertification.Bo" targetProject="java-generator-core/src/main/java">--> |
| 52 | + <!--<property name="enableSubPackages" value="true" />--> |
| 53 | + <!--<property name="trimStrings" value="true" />--> |
| 54 | + <!--</javaBoGenerator>--> |
| 55 | + <javaModelGenerator targetPackage="com.btjf.business.authentication.custcertification.model" targetProject="java-generator-core/src/main/java"> |
| 56 | + <property name="enableSubPackages" value="true" /> |
| 57 | + <property name="trimStrings" value="true" /> |
| 58 | + </javaModelGenerator> |
| 59 | + <sqlMapGenerator targetPackage="com.btjf.business.authentication.custcertification.mapper" targetProject="java-generator-core/src/main/java"> |
| 60 | + <property name="enableSubPackages" value="true" /> |
| 61 | + </sqlMapGenerator> |
| 62 | + <javaClientGenerator targetPackage="com.btjf.business.authentication.custcertification.mapper" targetProject="java-generator-core/src/main/java" type="XMLMAPPER"> |
| 63 | + <property name="enableSubPackages" value="true" /> |
| 64 | + </javaClientGenerator> |
| 65 | + <!--<javaServiceGenerator targetPackage="com.btjf.business.authentication.custcertification.service" targetProject="java-generator-core/src/main/java">--> |
| 66 | + <!--<property name="enableSubPackages" value="true" />--> |
| 67 | + <!--</javaServiceGenerator>--> |
| 68 | + <!--<javaDomainGenerator targetPackage="com.btjf.business.authentication.custcertification.domain"--> |
| 69 | + <!--targetProject="java-generator-core/src/main/java">--> |
| 70 | + <!--</javaDomainGenerator>--> |
| 71 | + |
| 72 | + <table tableName="t_Member" domainObjectName="Member" boObjectName="MemberBo" enableInsert="false" enableUpdateByExample = "false" enableSelectAll="true" enableSelectNotDeleteAll="true" |
| 73 | + enableSelectNotDeleteByPrimaryKey = "true" |
| 74 | + > |
| 75 | + <property name="useActualColumnNames" value="true"/> |
| 76 | + <generatedKey column="FID" sqlStatement="SELECT @@IDENTITY" identity="true"/> |
| 77 | + <columnRenamingRule searchString="^F" replaceString=""/> |
| 78 | + </table> |
| 79 | + </context> |
| 80 | + |
| 81 | +</generatorConfiguration> |
0 commit comments