zoukankan      html  css  js  c++  java
  • generatorConfiguration配置文件及其详细解读

    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.     <!-- 引入配置文件 -->  
    6.     <properties resource="jdbc.properties"/>  
    7.       
    8.     <!-- 指定数据连接驱动jar地址 -->  
    9.     <classPathEntry location="C:UsersAdministrator.m2 epositorymysqlmysql-connector-java5.1.30mysql-connector-java-5.1.30.jar" />  
    10.       
    11.     <!-- 一个数据库一个context -->  
    12.     <context id="FCRMTables">  
    13.         <!-- 注释 -->  
    14.         <commentGenerator >  
    15.             <property name="suppressAllComments" value="true"/><!-- 是否取消注释 -->  
    16.             <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳-->  
    17.         </commentGenerator>  
    18.           
    19.         <!-- jdbc连接 -->  
    20.         <jdbcConnection driverClass="${driverClassName}"  
    21.             connectionURL="${url}" userId="${username}"  
    22.             password="${password}" />  
    23.           
    24.         <!-- 类型转换 -->  
    25.         <javaTypeResolver>  
    26.             <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->  
    27.             <property name="forceBigDecimals" value="false"/>  
    28.         </javaTypeResolver>  
    29.           
    30.         <!-- 生成实体类的包名和位置 注意targetProject的值为实体类放在工程中具体位置的相对路径,-->  
    31.         <javaModelGenerator targetPackage="com.qlm.entity"  
    32.             targetProject="src/main/java" >  
    33.             <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->  
    34.             <property name="enableSubPackages" value="true"/>  
    35.             <!-- 是否针对string类型的字段在set的时候进行trim调用 -->  
    36.             <property name="trimStrings" value="true"/>  
    37.         </javaModelGenerator>  
    38.           
    39.         <!-- 生成的SQLMapper映射文件包名和位置 -->  
    40.         <sqlMapGenerator targetPackage="mybatisMapper"  
    41.             targetProject="src/main/resources" >  
    42.             <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->  
    43.             <property name="enableSubPackages" value="true" />  
    44.         </sqlMapGenerator>  
    45.           
    46.         <!-- 生成DAO的包名和位置,这里配置将生成的dao类放在me.gacl.dao这个包下 -->  
    47.         <javaClientGenerator targetPackage="com.qlm.dao"  
    48.             targetProject="src/main/java" type="XMLMAPPER" >  
    49.             <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->  
    50.             <property name="enableSubPackages" value="true" />  
    51.         </javaClientGenerator>  
    52.           
    53.         <!-- 配置表信息 -->  
    54.         <!-- schema即为数据库名 tableName为对应的数据库表 domainObjectName是要生成的实体类 enable*ByExample   
    55.                 是否生成 example类   -->    
    56.         <!-- 更改tableName和domainObjectName就可以 -->  
    57.         <table schema="qlm" tableName="tb_qlm_admin"  
    58.             domainObjectName="Admin" enableCountByExample="false"  
    59.             enableDeleteByExample="false" enableSelectByExample="false"  
    60.             enableUpdateByExample="false">             
    61.         </table>  
    62.     </context>  
    63. </generatorConfiguration>  

    jdbc.properties文件如下

    driverClassName=com.mysql.jdbc.Driver
    url=jdbc:mysql://localhost:3306/qlm?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
    username=root
    password=root

     

    运行-->Run As -->Maven build-->Goals填写mybatis-generator:generate--Run

  • 相关阅读:
    面试题--赵银科技
    面试题--乐视.滴滴
    面试题--CVTE
    面试题--美团
    面试题--百度
    面试题--京东 有用
    mybatis的执行流程 #{}和${} Mysql自增主键返回 resultMap 一对多 多对一配置
    SpringMVC第一天
    LeetCode -- Maximum Product Subarray
    LeetCode -- Product of Array Except Self My Submissions Question
  • 原文地址:https://www.cnblogs.com/jpfss/p/7561669.html
Copyright © 2011-2022 走看看