shard-mybatis-generator.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE generatorConfiguration
  3. PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  4. "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
  5. <generatorConfiguration>
  6. <context id="MySql" defaultModelType="flat">
  7. <!--搜索:need to change-->
  8. <!-- 查询单条数据插件 -->
  9. <plugin type="com.itfsw.mybatis.generator.plugins.SelectOneByExamplePlugin"/>
  10. <!-- MySQL分页插件 -->
  11. <plugin type="com.itfsw.mybatis.generator.plugins.LimitPlugin">
  12. <!-- 通过配置startPage影响Example中的page方法开始分页的页码,默认分页从0开始 -->
  13. <property name="startPage" value="0"/>
  14. </plugin>
  15. <!-- Example Criteria 增强插件 -->
  16. <plugin type="com.itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin">
  17. <!-- 是否支持已经过时的andIf方法(推荐使用when代替),默认支持 -->
  18. <property name="enableAndIf" value="true"/>
  19. </plugin>
  20. <!-- Example 目标包修改插件 need to change-->
  21. <plugin type="com.itfsw.mybatis.generator.plugins.ExampleTargetPlugin">
  22. <!-- 修改Example类生成到目标包下 -->
  23. <property name="targetPackage" value="com.book.dao.cpsshard.pojo.example"/>
  24. </plugin>
  25. <!-- 数据Model属性对应Column获取插件 -->
  26. <plugin type="com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"/>
  27. <!-- 数据Model链式构建插件 -->
  28. <plugin type="com.itfsw.mybatis.generator.plugins.ModelBuilderPlugin"/>
  29. <!-- 批量插入插件 -->
  30. <plugin type="com.itfsw.mybatis.generator.plugins.BatchInsertPlugin">
  31. <!--
  32. 开启后可以实现官方插件根据属性是否为空决定是否插入该字段功能
  33. !需开启allowMultiQueries=true多条sql提交操作,所以不建议使用!插件默认不开启
  34. -->
  35. <property name="allowMultiQueries" value="false"/>
  36. </plugin>
  37. <!-- 存在即更新插件 -->
  38. <plugin type="com.itfsw.mybatis.generator.plugins.UpsertPlugin">
  39. <!--
  40. 支持upsertByExample,upsertByExampleSelective操作
  41. !需开启allowMultiQueries=true多条sql提交操作,所以不建议使用!插件默认不开启
  42. -->
  43. <property name="allowMultiQueries" value="false"/>
  44. <!--
  45. 开启批量功能,支持batchUpsert,batchUpsertWithBLOBs,batchUpserSelective
  46. !这几个方法中无法支持IncrementsPlugin的方法!插件默认不开启
  47. -->
  48. <property name="allowBatchUpsert" value="fasle"/>
  49. </plugin>
  50. <!-- 增量插件 -->
  51. <plugin type="com.itfsw.mybatis.generator.plugins.IncrementPlugin"/>
  52. <!--<table tableName="tb">-->
  53. <!--&lt;!&ndash; 配置需要进行增量操作的列名称(英文半角逗号分隔) &ndash;&gt;-->
  54. <!--<property name="incrementColumns" value="field1,field2"/>-->
  55. <!--</table>-->
  56. <!-- 查询结果选择性返回插件 -->
  57. <plugin type="com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin"/>
  58. <!-- Selective选择插入更新增强插件 -->
  59. <plugin type="com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"/>
  60. <!-- Lombok插件 -->
  61. <plugin type="com.itfsw.mybatis.generator.plugins.LombokPlugin">
  62. <!-- @Data 默认开启,同时插件会对子类自动附加@EqualsAndHashCode(callSuper = true),@ToString(callSuper = true) -->
  63. <property name="@Data" value="true"/>
  64. <!-- @Builder 必须在 Lombok 版本 >= 1.18.2 的情况下开启,对存在继承关系的类自动替换成@SuperBuilder -->
  65. <property name="@Builder" value="false"/>
  66. <!-- @NoArgsConstructor 和 @AllArgsConstructor 使用规则和Lombok一致 -->
  67. <property name="@AllArgsConstructor" value="false"/>
  68. <property name="@NoArgsConstructor" value="false"/>
  69. <!-- @Getter、@Setter、@Accessors 等使用规则参见官方文档 -->
  70. <property name="@Accessors(chain = true)" value="false"/>
  71. <!-- 临时解决IDEA工具对@SuperBuilder的不支持问题,开启后(默认未开启)插件在遇到@SuperBuilder注解时会调用ModelBuilderPlugin来生成相应的builder代码 -->
  72. <property name="supportSuperBuilderForIdea" value="false"/>
  73. </plugin>
  74. <plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
  75. <!-- Mapper注解插件 -->
  76. <plugin type="com.itfsw.mybatis.generator.plugins.MapperAnnotationPlugin">
  77. <!-- @Mapper 默认开启 -->
  78. <property name="@Mapper" value="true"/>
  79. <!-- @Repository 默认关闭,开启后解决IDEA工具@Autowired报错 -->
  80. <property name="@Repository" value="true"/>
  81. </plugin>
  82. <!--<plugin type="org.mybatis.generator.plugins.ToStringPlugin" />-->
  83. <!--数据库连接配置 need to change-->
  84. <jdbcConnection
  85. driverClass="com.mysql.cj.jdbc.Driver"
  86. connectionURL="jdbc:mysql://121.41.100.198:3306/test_cps_shard_192?nullCatalogMeansCurrent=true&amp;serverTimezone=UTC"
  87. userId="root"
  88. password="root"/>
  89. <!--指定自动生成的 POJO置于哪个包下 need to change -->
  90. <javaModelGenerator targetPackage="com.book.dao.cpsshard.entity"
  91. targetProject="src/main/java"/>
  92. <!--指定自动生成的 mapper.xml置于哪个包下 -->
  93. <sqlMapGenerator targetPackage="mapper/cpsshard" targetProject="src/main/resources"/>
  94. <!--指定自动生成的 DAO接口置于哪个包下 need to change-->
  95. <javaClientGenerator targetPackage="com.book.dao.cpsshard.mapper"
  96. targetProject="src/main/java" type="XMLMAPPER"/>
  97. <!--指定数据表名,可以使用_和%通配符,可以配置generatedKey,会返回insert之后的id-->
  98. <table tableName="user_recently_read"/>
  99. <table tableName="sign"/>
  100. <table tableName="recharge"/>
  101. <table tableName="consume"/>
  102. </context>
  103. </generatorConfiguration>