• MBG(Mybatis Generator)配置


    配置需注意2点,

    1.对于匹配所有表用%,多表配合使用_和%,这个和SQL Like查询模糊匹配方法一致

    2.配置报错的话,提示如下:标黄的部分其实是正则表达式

    The content of element type "context" is incomplete, it must match
    "(property*,plugin*,commentGenerator?,(connectionFactory|
    jdbcConnection),javaTypeResolver?,javaModelGenerator,sqlMapGenerator?,javaClientGenerator?,table+)".

    真实项目范例:

     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 
     6 <generatorConfiguration>
     7     <!--<properties resource="application.properties"/>-->
     8 
     9     <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
    10         <property name="beginningDelimiter" value="`"/>
    11         <property name="endingDelimiter" value="`"/>
    12 
    13         <!-- 数据源配置开始 -->
    14         <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
    15             <property name="mappers" value="com.qfpie.server.util.QkMapper"/>
    16         </plugin>
    17          <jdbcConnection driverClass="com.mysql.jdbc.Driver"
    18                         connectionURL="jdbc:mysql://172.**.**.**:3306/qone"
    19                         userId="qkapp"
    20                         password="*********">
    21         </jdbcConnection> 
    22         
    23         <javaModelGenerator targetPackage="com.qfpie.server.model.qone" targetProject="src/main/java"/>
    24         <sqlMapGenerator targetPackage="mapper.qone" targetProject="src/main/resources"/>
    25         <javaClientGenerator targetPackage="com.qfpie.server.mapper.mysql.qone" targetProject="src/main/java"
    26                              type="XMLMAPPER"/>
    27                     
    28         <!-- 数据源配置结束 -->         
    29 
    30         <table tableName="cobra_text" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
    31             <!--% 表示全部表-->
    32             <!--mysql 配置-->
    33             <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
    34             <!--oracle 配置-->
    35          <!--    <generatedKey column="ID" sqlStatement="select SEQ_{1}.nextval from dual" identity="false" type="pre"/>  -->
    36         </table>
    37     </context>
    38 </generatorConfiguration>
  • 相关阅读:
    关于Lucas定理、多项式Exp的一些思考
    Binet-Cauchy定理的证明
    CSP2019 树上的数 题解
    Graphviz学习
    Luogu P2221 [HAOI2012]高速公路题解
    CSP2019 树的重心 题解
    CSP2019 Emiya 家今天的饭 题解
    UVA10559 方块消除 Blocks 题解
    关于二次项系数为1的二元一次不定方程解法的探究
    关于对STL容器重载运算符的问题
  • 原文地址:https://www.cnblogs.com/researcher/p/7479298.html
Copyright © 2020-2023  润新知