generatorConfig.vm 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
  3. <generatorConfiguration>
  4. <!-- 配置文件 -->
  5. <properties resource="jdbc.properties"></properties>
  6. <!-- mysql驱动包 -->
  7. <classPathEntry location="${classPathEntry}" />
  8. <context id="MysqlContext" targetRuntime="MyBatis3" defaultModelType="flat">
  9. <property name="javaFileEncoding" value="UTF-8"/>
  10. <!-- 由于beginningDelimiter和endingDelimiter的默认值为双引号("),在Mysql中不能这么写,所以还要将这两个默认值改为` -->
  11. <property name="beginningDelimiter" value="`"/>
  12. <property name="endingDelimiter" value="`"/>
  13. <!-- 为生成的Java模型创建一个toString方法 -->
  14. <plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
  15. <!-- 为生成的Java模型类添加序列化接口,并生成serialVersionUID字段 -->
  16. <plugin type="com.zheng.common.plugin.SerializablePlugin">
  17. <property name="suppressJavaInterface" value="false"/>
  18. </plugin>
  19. <!-- 生成一个新的selectByExample方法,这个方法可以接收offset和limit参数,主要用来实现分页 -->
  20. <plugin type="com.zheng.common.plugin.PaginationPlugin"></plugin>
  21. <!-- 生成在XML中的<cache>元素 -->
  22. <plugin type="org.mybatis.generator.plugins.CachePlugin">
  23. <!-- 使用ehcache -->
  24. <property name="cache_type" value="org.mybatis.caches.ehcache.LoggingEhcache" />
  25. <!-- 内置cache配置 -->
  26. <!--
  27. <property name="cache_eviction" value="LRU" />
  28. <property name="cache_flushInterval" value="60000" />
  29. <property name="cache_readOnly" value="true" />
  30. <property name="cache_size" value="1024" />
  31. -->
  32. </plugin>
  33. <!-- Java模型生成equals和hashcode方法 -->
  34. <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin>
  35. <!-- 生成的代码去掉注释 -->
  36. <commentGenerator type="com.zheng.common.plugin.CommentGenerator">
  37. <property name="suppressAllComments" value="true" />
  38. <property name="suppressDate" value="true"/>
  39. </commentGenerator>
  40. <!-- 数据库连接 -->
  41. <jdbcConnection driverClass="${jdbc.driver}"
  42. connectionURL="${jdbc.url}"
  43. userId="${jdbc.username}"
  44. password="${jdbc.password}" />
  45. <!-- model生成 -->
  46. <javaModelGenerator targetPackage="${generator_javaModelGenerator_targetPackage}" targetProject="${targetProject}/src/main/java" />
  47. <!-- MapperXML生成 -->
  48. <sqlMapGenerator targetPackage="${generator_sqlMapGenerator_targetPackage}" targetProject="${targetProject}/src/main/java" />
  49. <!-- Mapper接口生成 -->
  50. <javaClientGenerator targetPackage="${generator_javaClientGenerator_targetPackage}" targetProject="${targetProject}/src/main/java" type="XMLMAPPER" />
  51. <!-- 需要映射的表 -->
  52. #foreach($table in $tables)
  53. <table tableName="$!table.table_name" domainObjectName="$!table.model_name"></table>
  54. #end
  55. </context>
  56. </generatorConfiguration>