generatorConfig.xml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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="context" targetRuntime="MyBatis3">
  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="org.mybatis.generator.plugins.SerializablePlugin">
  17. <property name="suppressJavaInterface" value="false"/>
  18. </plugin>
  19. <!-- 生成一个新的selectByExample方法,这个方法可以接受一个RowBounds参数,主要用来实现分页 -->
  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>
  37. <property name="suppressAllComments" value="true" />
  38. </commentGenerator>
  39. <!-- 数据库连接 -->
  40. <jdbcConnection driverClass="${jdbc.driver}"
  41. connectionURL="${jdbc.url}"
  42. userId="${jdbc.username}"
  43. password="${jdbc.password}" />
  44. <!-- model生成 -->
  45. <javaModelGenerator targetPackage="${generator.javaModelGenerator.targetPackage}" targetProject="src/main/java" />
  46. <!-- MapperXML生成 -->
  47. <sqlMapGenerator targetPackage="${generator.sqlMapGenerator.targetPackage}" targetProject="src/main/java" />
  48. <!-- Mapper接口生成 -->
  49. <javaClientGenerator targetPackage="${generator.javaClientGenerator.targetPackage}" targetProject="src/main/java" type="XMLMAPPER" />
  50. <!-- 需要映射的表 -->
  51. <table tableName="user" domainObjectName="User">
  52. <generatedKey column="id" sqlStatement="MySql" identity="true" />
  53. </table>
  54. <table tableName="book" domainObjectName="Book">
  55. <generatedKey column="id" sqlStatement="MySql" identity="true" />
  56. </table>
  57. </context>
  58. </generatorConfiguration>