1、MyBatis Generator 诞生背景

虽然MyBatis是一个简单易学的框架,但是配置XML文件也是一件相当繁琐的一个过程,而且会出现很多不容易定位的错误。当在工作中需要生成大量对象的时候,有太多的重复劳动,简直是生无可恋。所以,官方开发了 MyBatis Generator。它只需要很少量的简单配置,就可以完成大量的表到Java对象的生成工作,拥有零出错和速度快的优点,让开发人员解放出来更专注于业务逻辑的开发。

2、MyBatis Generator 简介

官网的MyBatis Generator使用介绍,请点击下面的链接:

http://mybatis.org/generator/index.html

MyBatis Generator,简称MBG,当前版本是1.4.0,发布时间是:2019年11月24日

MyBatis Generator 生成的文件包含三类:

(1)Model实体文件,一个数据库表对应生成一个 Model 实体;
(2)Mapper接口文件,数据数操作方法都在此接口中定义;
(3)Mapper XML配置文件

3、MyBatis Generator的使用介绍:

下载MyBatis Generator之后,配置generatorConfig.xml文件,然后通过命令行就可以运行MyBatis Generator,如下所示:

java -jar mybatis-generator-core-x.x.x.jar -configfile \temp\generatorConfig.xml -overwrite

当然,MyBatis Generator的使用还可以有其他多种方式,如下所示:

MyBatis Generator (MBG) can be run in the following ways:

From the command prompt with an XML configuration
As an Ant task with an XML configuration
As a Maven Plugin
From another Java program with an XML configuration
From another Java program with a Java based configuration
As an Eclipse Feature

具体的介绍,请移步官方文档:http://mybatis.org/generator/running/running.html

4、MyBatis generatorConfig 配置文件介绍:

http://mybatis.org/generator/configreference/xmlconfig.html

标签: none

[网站公告]-[2024年兼职介绍]


添加新评论