generatorConfig.xml 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. <context id="MysqlContext" targetRuntime="MyBatis3" defaultModelType="flat">
  7. <property name="javaFileEncoding" value="UTF-8"/>
  8. <!-- 由于beginningDelimiter和endingDelimiter的默认值为双引号("),在Mysql中不能这么写,所以还要将这两个默认值改为` -->
  9. <property name="beginningDelimiter" value="`"/>
  10. <property name="endingDelimiter" value="`"/>
  11. <!-- 为生成的Java模型创建一个toString方法 -->
  12. <plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
  13. <!-- 为生成的Java模型类添加序列化接口,并生成serialVersionUID字段 -->
  14. <plugin type="com.zheng.common.plugin.SerializablePlugin">
  15. <property name="suppressJavaInterface" value="false"/>
  16. </plugin>
  17. <!-- 生成一个新的selectByExample方法,这个方法可以接收offset和limit参数,主要用来实现分页 -->
  18. <plugin type="com.zheng.common.plugin.PaginationPlugin"></plugin>
  19. <!-- 生成在XML中的<cache>元素 -->
  20. <plugin type="org.mybatis.generator.plugins.CachePlugin">
  21. <!-- 使用ehcache -->
  22. <property name="cache_type" value="org.mybatis.caches.ehcache.LoggingEhcache" />
  23. <!-- 内置cache配置 -->
  24. <!--
  25. <property name="cache_eviction" value="LRU" />
  26. <property name="cache_flushInterval" value="60000" />
  27. <property name="cache_readOnly" value="true" />
  28. <property name="cache_size" value="1024" />
  29. -->
  30. </plugin>
  31. <!-- Java模型生成equals和hashcode方法 -->
  32. <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin>
  33. <!-- 生成的代码去掉注释 -->
  34. <commentGenerator type="com.zheng.common.plugin.CommentGenerator">
  35. <property name="suppressAllComments" value="true" />
  36. <property name="suppressDate" value="true"/>
  37. </commentGenerator>
  38. <!-- 数据库连接 -->
  39. <jdbcConnection driverClass="${master.jdbc.driver}"
  40. connectionURL="${master.jdbc.url}"
  41. userId="${master.jdbc.username}"
  42. password="${master.jdbc.password}" />
  43. <!-- model生成 -->
  44. <javaModelGenerator targetPackage="com.zheng.cms.dao.model" targetProject="zheng-cms/zheng-cms-dao/src/main/java" />
  45. <!-- MapperXML生成 -->
  46. <sqlMapGenerator targetPackage="com.zheng.cms.dao.mapper" targetProject="zheng-cms/zheng-cms-dao/src/main/java" />
  47. <!-- Mapper接口生成 -->
  48. <javaClientGenerator targetPackage="com.zheng.cms.dao.mapper" targetProject="zheng-cms/zheng-cms-dao/src/main/java" type="XMLMAPPER" />
  49. <!-- 需要映射的表 -->
  50. <table tableName="cms_article" domainObjectName="CmsArticle"></table>
  51. <table tableName="cms_article_category" domainObjectName="CmsArticleCategory"></table>
  52. <table tableName="cms_article_tag" domainObjectName="CmsArticleTag"></table>
  53. <table tableName="cms_book" domainObjectName="CmsBook"></table>
  54. <table tableName="cms_category" domainObjectName="CmsCategory"></table>
  55. <table tableName="cms_category_tag" domainObjectName="CmsCategoryTag"></table>
  56. <table tableName="cms_comment" domainObjectName="CmsComment"></table>
  57. <table tableName="cms_page" domainObjectName="CmsPage"></table>
  58. <table tableName="cms_setting" domainObjectName="CmsSetting"></table>
  59. <table tableName="cms_tag" domainObjectName="CmsTag"></table>
  60. <table tableName="cms_user" domainObjectName="CmsUser"></table>
  61. </context>
  62. </generatorConfiguration>