逆向生成也就是使用插件,根据数据库表、字段、类型自动生成对应的Mybatis的Dao、Mapper、Entity
<?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>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<classPathEntry location="E:\Maven\maven-jar\com\oracle\ojdbc6\11.2.0.3\ojdbc6-11.2.0.3.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="oracle.jdbc.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
userId="EF_DNEVA"
password="123456">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成实体类的包名和位置-->
<javaModelGenerator targetPackage="top.ygang.entity"
targetProject="E:\javaproject\后台代码\southeast-evaluation\src\main\java">
</javaModelGenerator>
<!-- 生成映射文件xml的包名和位置-->
<sqlMapGenerator targetPackage="mapper"
targetProject="E:\javaproject\后台代码\southeast-evaluation\src\main\resources">
</sqlMapGenerator>
<!-- 生成mapper接口位置-->
<javaClientGenerator type="XMLMAPPER"
targetPackage="top.ygang.dao"
targetProject="E:\javaproject\后台代码\southeast-evaluation\src\main\java">
</javaClientGenerator>
<!-- 自定义要生成的表-->
<table schema="" tableName="t_sb_bj" ></table>
<table schema="" tableName="t_zxjc_ysp" ></table>
<table schema="" tableName="t_zxjc_sf6" ></table>
<table schema="" tableName="t_zxjc_jczz" ></table>
<table schema="" tableName="t_zxjc_jbfd" ></table>
<table schema="" tableName="t_sy_sysj" ></table>
<table schema="" tableName="t_sy_syjl" ></table>
<table schema="" tableName="t_sb_ycsbzb" ></table>
<table schema="" tableName="t_sb_dz" ></table>
<table schema="" tableName="t_qx_qxjl" ></table>
<table schema="" tableName="t_jx_jxjl" ></table>
<table schema="" tableName="t_gz_gzjl" ></table>
<table schema="" tableName="t_gj_gjjl" ></table>
</context>
</generatorConfiguration>
better-mybatis-generator
、EasyCode
==将插件中两个文件夹中的文件,复制进eclipse安装目录,并重启==
<?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 -->
<context id="context1">
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<commentGenerator>
<property name="suppressDate" value="true" />
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- jdbc连接 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/stu?characterEncoding=utf-8"
userId="root"
password="123456">
</jdbcConnection>
<!-- 生成实体类地址 -->
<javaModelGenerator targetPackage="top.ygang.entity" targetProject="web20210629" >
</javaModelGenerator>
<!-- 生成mapxml文件 -->
<sqlMapGenerator targetPackage="top.ygang.mapper" targetProject="web20210629" >
</sqlMapGenerator>
<!-- 生成mapxmldao接口 -->
<javaClientGenerator targetPackage="top.ygang.mapper"
targetProject="web20210629" type="XMLMAPPER" >
</javaClientGenerator>
<!-- 配置表信息 -->
<table schema="" tableName="student" ></table>
</context>
</generatorConfiguration>