generatorConfig.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. <!-- 引入配置文件 -->
  7. <!-- <properties resource="datasource.properties"></properties>-->
  8. <!--指定特定数据库的jdbc驱动jar包的位置-->
  9. <classPathEntry location="/Users/baiyahui/.m2/repository/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar"/>
  10. <!-- 目标数据库 -->
  11. <!-- 一个数据库一个context, context子元素必须按照如下顺序
  12. property*、plugin*、commentGenerator?、jdbcConnection、javaTypeResolver?
  13. javaModelGenerator、sqlMapGenerator?、javaClientGenerator?、table+
  14. -->
  15. <!--id : 随便填,保证多个 context id 不重复就行
  16. defaultModelType : 可以不填,默认值 conditional,flat表示一张表对应一个po
  17. targetRuntime :可以不填,默认值 MyBatis3,常用的还有 MyBatis3Simple,这个配置会影响生成的 dao 和 mapper.xml的内容
  18. targetRuntime = MyBatis3Simple,生成的 dao 和 mapper.xml,接口方法会少很多,只包含最最常用的
  19. -->
  20. <context id="myContext" targetRuntime="MyBatis3">
  21. <!-- 生成java文件的编码格式 -->
  22. <property name="javaFileEncoding" value="UTF-8"/>
  23. <!-- 格式化java代码 -->
  24. <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
  25. <!-- 格式化XML代码 -->
  26. <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
  27. <!-- 生成的pojo,将implements Serializable -->
  28. <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
  29. <!-- 为生成的pojo创建一个toString方法 -->
  30. <!-- <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>-->
  31. <!-- 生成的pojo,增加了equals 和 hashCode方法-->
  32. <!-- <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />-->
  33. <!--生成mapper.xml时覆盖原文件-->
  34. <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
  35. <!-- 自定义注释 -->
  36. <commentGenerator>
  37. <!-- 是否去除自动生成的注释 true:是 : false:否 -->
  38. <property name="suppressAllComments" value="true"/>
  39. <property name="suppressDate" value="false"/>
  40. <!--添加 db 表中字段的注释-->
  41. <property name="addRemarkComments" value="true"/>
  42. </commentGenerator>
  43. <!--数据库连接信息:驱动类、链接地址、用户名、密码 -->
  44. <jdbcConnection driverClass="com.mysql.jdbc.Driver"
  45. connectionURL="jdbc:mysql://192.168.50.233:3306/energy?useUnicode=true"
  46. userId="admin"
  47. password="admin123456">
  48. <!--高版本的 mysql-connector-java 需要设置 nullCatalogMeansCurrent=true-->
  49. <!--解决mysql驱动升级到8.0后不生成指定数据库代码的问题-->
  50. <property name="nullCatalogMeansCurrent" value="true"/>
  51. </jdbcConnection>
  52. <javaTypeResolver>
  53. <!--类型解析器-->
  54. <!-- 默认false,把jdbc decimal 和 numeric 类型解析为integer -->
  55. <!-- true,把jdbc decimal 和 numeric 类型解析为java.math.bigdecimal-->
  56. <property name="forceBigDecimals" value="true"/>
  57. <!--默认false
  58. false,将所有 JDBC 的时间类型解析为 java.util.Date
  59. true,将 JDBC 的时间类型按如下规则解析
  60. DATE -> java.time.LocalDate
  61. TIME -> java.time.LocalTime
  62. TIMESTAMP -> java.time.LocalDateTime
  63. TIME_WITH_TIMEZONE -> java.time.OffsetTime
  64. TIMESTAMP_WITH_TIMEZONE -> java.time.OffsetDateTime
  65. -->
  66. <property name="useJSR310Types" value="false"/>
  67. </javaTypeResolver>
  68. <!-- java实体类路径 -->
  69. <javaModelGenerator targetPackage="com.energy.manage.common.po.detectionpointdic" targetProject="src/main/java">
  70. <!-- for MyBatis3/MyBatis3Simple
  71. 自动为每一个生成的类创建一个构造方法,构造方法包含了所有的field;而不是使用setter;
  72. -->
  73. <property name="constructorBased" value="false"/>
  74. <!-- 是否让schema作为包后缀 默认是false
  75. 会在 po 目录下在创建一个 “数据库名” 的文件夹,生成的 po 会放在该文件夹下,也就是说会多一层目录
  76. -->
  77. <property name="enableSubPackages" value="false"/>
  78. <!-- 从数据库返回的值被清理前后的空格-->
  79. <property name="trimStrings" value="true"/>
  80. </javaModelGenerator>
  81. <!-- 生成映射文件xml的包名和位置-->
  82. <sqlMapGenerator targetPackage="mybatis.detectionpointdic" targetProject="src/main/resources">
  83. <!-- 是否让schema作为包后缀-->
  84. <property name="enableSubPackages" value="false"/>
  85. </sqlMapGenerator>
  86. <!-- 生成Mapper接口的包名和位置
  87. type="XMLMAPPER" 会将接口的实现放在 mapper.xml中,也推荐这样配置。
  88. type="ANNOTATEDMAPPER",接口的实现通过注解写在接口上面
  89. -->
  90. <javaClientGenerator type="XMLMAPPER" targetPackage="com.energy.manage.service.mappers.detectionpointdic"
  91. targetProject="src/main/java">
  92. <!-- 是否让schema作为包后缀-->
  93. <property name="enableSubPackages" value="false"/>
  94. </javaClientGenerator>
  95. <!-- 用于自动生成代码的数据库表;生成哪些表;
  96. schema为数据库名,oracle需要配置,mysql不需要配置。
  97. tableName为对应的数据库表名
  98. domainObjectName 是要生成的实体类名(可以不指定)(其中 domainObjectName 不配置时,它会按照帕斯卡命名法将表名转换成类名)
  99. enableXXXByExample 默认为 true, 为 true 会生成一个对应Example帮助类,帮助你进行条件查询,不想要可以设为false
  100. 生成全部表tableName设为 %
  101. -->
  102. <table tableName="detection_point_dic" domainObjectName="DetectionPointDic"
  103. enableDeleteByExample="false"
  104. enableCountByExample="false"
  105. enableSelectByExample="false"
  106. enableUpdateByExample="false"></table>
  107. </context>
  108. </generatorConfiguration>