mybatis-generator.xml 6.1 KB

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