1、 使用mybatis逆向工程的步骤如下:
在pom.xml文件中添加mybatis 逆向工程所需要的jar包(到maven中央仓库搜索mybatis generator就行)
打开mybatis generator的文档,地址为http://www.mybatis.org/generator/configreference/commentGenerator.html
mybatis generator中文文档,地址为 http://mbg.cndocs.ml/quickstart.html
在该文档中找到快速开始提供给我们的配置文件,并且更改配置文件。需要改的地方有“bean生成规则”“mapper接口生成规则”“实体映射xml生成规则”以及我们的数据表、数据库连接的基本数据
在文档中找到测试类,把测试类粘贴到我们工程中运行就会生成实体类、mapper接口、xml文件了。
创建逆向工程:1.在pom.xml文件中添加mybatis 逆向工程所需要的jar包
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
2.添加测试类,在测试文件下创建一个类作为测试类:(测试类在mybatis generator下/运行mybatis Generator/从另一个Java 程序使用xml配置文件)(
测试类
)
2.配置文件
com.zhiyuan.pojo:实体类
com.zhiyuan.dao:接口
Mapper:映射文件
是否去除自动生成的注释 true:是 : false:否
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>