123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE generatorConfiguration
- PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
- "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
- <generatorConfiguration>
- <!-- 引入配置文件 -->
- <!-- <properties resource="datasource.properties"></properties>-->
- <!--指定特定数据库的jdbc驱动jar包的位置-->
- <classPathEntry location="/Users/baiyahui/.m2/repository/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar"/>
- <!-- 目标数据库 -->
- <!-- 一个数据库一个context, context子元素必须按照如下顺序
- property*、plugin*、commentGenerator?、jdbcConnection、javaTypeResolver?
- javaModelGenerator、sqlMapGenerator?、javaClientGenerator?、table+
- -->
- <!--id : 随便填,保证多个 context id 不重复就行
- defaultModelType : 可以不填,默认值 conditional,flat表示一张表对应一个po
- targetRuntime :可以不填,默认值 MyBatis3,常用的还有 MyBatis3Simple,这个配置会影响生成的 dao 和 mapper.xml的内容
- targetRuntime = MyBatis3Simple,生成的 dao 和 mapper.xml,接口方法会少很多,只包含最最常用的
- -->
- <context id="myContext" targetRuntime="MyBatis3">
- <!-- 生成java文件的编码格式 -->
- <property name="javaFileEncoding" value="UTF-8"/>
- <!-- 格式化java代码 -->
- <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
- <!-- 格式化XML代码 -->
- <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
- <!-- 生成的pojo,将implements Serializable -->
- <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
- <!-- 为生成的pojo创建一个toString方法 -->
- <!-- <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>-->
- <!-- 生成的pojo,增加了equals 和 hashCode方法-->
- <!-- <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />-->
- <!--生成mapper.xml时覆盖原文件-->
- <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
- <!-- 自定义注释 -->
- <commentGenerator>
- <!-- 是否去除自动生成的注释 true:是 : false:否 -->
- <property name="suppressAllComments" value="true"/>
- <property name="suppressDate" value="false"/>
- <!--添加 db 表中字段的注释-->
- <property name="addRemarkComments" value="true"/>
- </commentGenerator>
- <!--数据库连接信息:驱动类、链接地址、用户名、密码 -->
- <jdbcConnection driverClass="com.mysql.jdbc.Driver"
- connectionURL="jdbc:mysql://192.168.50.233:3306/energy?useUnicode=true"
- userId="admin"
- password="admin123456">
- <!--高版本的 mysql-connector-java 需要设置 nullCatalogMeansCurrent=true-->
- <!--解决mysql驱动升级到8.0后不生成指定数据库代码的问题-->
- <property name="nullCatalogMeansCurrent" value="true"/>
- </jdbcConnection>
- <javaTypeResolver>
- <!--类型解析器-->
- <!-- 默认false,把jdbc decimal 和 numeric 类型解析为integer -->
- <!-- true,把jdbc decimal 和 numeric 类型解析为java.math.bigdecimal-->
- <property name="forceBigDecimals" value="true"/>
- <!--默认false
- false,将所有 JDBC 的时间类型解析为 java.util.Date
- true,将 JDBC 的时间类型按如下规则解析
- DATE -> java.time.LocalDate
- TIME -> java.time.LocalTime
- TIMESTAMP -> java.time.LocalDateTime
- TIME_WITH_TIMEZONE -> java.time.OffsetTime
- TIMESTAMP_WITH_TIMEZONE -> java.time.OffsetDateTime
- -->
- <property name="useJSR310Types" value="false"/>
- </javaTypeResolver>
- <!-- java实体类路径 -->
- <javaModelGenerator targetPackage="com.energy.manage.common.po.detectionpointdic" targetProject="src/main/java">
- <!-- for MyBatis3/MyBatis3Simple
- 自动为每一个生成的类创建一个构造方法,构造方法包含了所有的field;而不是使用setter;
- -->
- <property name="constructorBased" value="false"/>
- <!-- 是否让schema作为包后缀 默认是false
- 会在 po 目录下在创建一个 “数据库名” 的文件夹,生成的 po 会放在该文件夹下,也就是说会多一层目录
- -->
- <property name="enableSubPackages" value="false"/>
- <!-- 从数据库返回的值被清理前后的空格-->
- <property name="trimStrings" value="true"/>
- </javaModelGenerator>
- <!-- 生成映射文件xml的包名和位置-->
- <sqlMapGenerator targetPackage="mybatis.detectionpointdic" targetProject="src/main/resources">
- <!-- 是否让schema作为包后缀-->
- <property name="enableSubPackages" value="false"/>
- </sqlMapGenerator>
- <!-- 生成Mapper接口的包名和位置
- type="XMLMAPPER" 会将接口的实现放在 mapper.xml中,也推荐这样配置。
- type="ANNOTATEDMAPPER",接口的实现通过注解写在接口上面
- -->
- <javaClientGenerator type="XMLMAPPER" targetPackage="com.energy.manage.service.mappers.detectionpointdic"
- targetProject="src/main/java">
- <!-- 是否让schema作为包后缀-->
- <property name="enableSubPackages" value="false"/>
- </javaClientGenerator>
- <!-- 用于自动生成代码的数据库表;生成哪些表;
- schema为数据库名,oracle需要配置,mysql不需要配置。
- tableName为对应的数据库表名
- domainObjectName 是要生成的实体类名(可以不指定)(其中 domainObjectName 不配置时,它会按照帕斯卡命名法将表名转换成类名)
- enableXXXByExample 默认为 true, 为 true 会生成一个对应Example帮助类,帮助你进行条件查询,不想要可以设为false
- 生成全部表tableName设为 %
- -->
- <table tableName="detection_point_dic" domainObjectName="DetectionPointDic"
- enableDeleteByExample="false"
- enableCountByExample="false"
- enableSelectByExample="false"
- enableUpdateByExample="false"></table>
- </context>
- </generatorConfiguration>
|