• Eclipse插件:mybatis-generator的使用


    在使用MyBatis进行项目开发时,建好数据库表后,手动创建Pojo,Mapper以及对应的xml映射文件时,会进行大量重复性的工作。使用MyBatis-Generator生成相应文件后,再修改,可以缩短这部分工作的时间。

    1、安装mybatis generator插件。

    2、已有项目生成配置文件:new>>other>>MyBatis  Generator Configuration File。

    3、点击next后,会选择项目和修改文件名。点击Finish后会在项目下生成generatorConfig.xml。

    4、修改配置文件,配置mysql相关配置,配置生成pojo类,mapper类和mapper映射文件位置。

    <?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>
        <context id="context1">
            <jdbcConnection
                connectionURL="jdbc:mysql://127.0.0.1:3306/keep_account?useSSL=false"
                driverClass="com.mysql.jdbc.Driver" password="admin" userId="root" />
            <javaModelGenerator targetPackage="com.lidq.pojo"
                targetProject="keepAccountApi/src/main/java" />
            <sqlMapGenerator targetPackage="com.lidq.mapper"
                targetProject="keepAccountApi/src/main/java" />
            <javaClientGenerator targetPackage="com.lidq.mapper"
                targetProject="keepAccountApi/src/main/java" type="XMLMAPPER" />
            <table tableName="user">
            </table>
        </context>
    </generatorConfiguration>

    5、右键generatorConfig.xml >> Run as >> Run MyBatis Generator,会生成相应配置文件,并且已经加入了一些操作。

    更多配置参考 http://www.mybatis.org/generator/configreference/xmlconfig.html

  • 相关阅读:
    PLSQL学习笔记 wm_concat
    Oracle ERP 公司间往来的解决方案(转载)
    Excel单元格设成只读
    PLSQL笔记 存在性检查
    PL/SQL编程技巧
    查看Oracle EBS克隆Clone时间
    用wm_concat合并行及merge into更新
    商务英语900句
    外企公司常用英文缩写
    ASP.NET 2.0 XML 系列(5):用XmlReader读取XML文档
  • 原文地址:https://www.cnblogs.com/lideqiang/p/9067823.html
Copyright © 2020-2023  润新知