好好编程 - 物流项目 04【Mybatis 逆向工程】
2.1 新建数据库
2.2 导入 sql 脚本
脚本放在 logistics-manager-web 的 source 目录下
同步到 GitHub 上
3.1Eclipse 安装插件
如果 eclipse 中还没有安装 Generate 插件,那么按照如下步骤安装即可。
3.2 反向生成代码
创建一个普通 java 项目即可
在 src 下创建一个 generatorConfig.xml 文件。内容如下:
<?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="C:\Users\dengp.m2\repository\mysql\mysql-connector-java\5.1.27\mysql-connector-java-5.1.27.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/logistics"
userId="root"
password="123456">
</jdbcConnection>
<!-- <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@localhost:1521:XE"
userId="car"
password="car">
</jdbcConnection> -->
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="com.bobo.pojo" targetProject="GeneratorSqlMapCustom\src">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.bobo.mapper" targetProject="GeneratorSqlMapCustom\src">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.bobo.mapper" targetProject="GeneratorSqlMapCustom\src">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="t_basicdata" domainObjectName="BasicData" schema="" ></table>
<table tableName="t_customer" domainObjectName="Customer" schema=""></table>
<table tableName="t_menu" domainObjectName="Menu" schema=""></table>
<table tableName="t_order" domainObjectName="Order" schema=""></table>
<table tableName="t_order_detail" domainObjectName="OrderDetail" schema=""></table>
<table tableName="t_role" domainObjectName="Role" schema=""></table>
<table tableName="t_user" domainObjectName="User" schema=""></table>
</context>
</generatorConfiguration>
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190320174031916.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,
text_aHR0cHM6Ly9kcGItYm9ib2thb3lhLXNtLmJsb2cuY3Nkbi5uZXQ=,size_16,color_FFFFFF,t_70)
评论