逆向工程

一、逆向工程(srpingboot)

resources中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>
    
    <!-- 指定数据库驱动jar包 -->
    <classPathEntry location="D:\develop\maven-repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
    
    <context id="context1">
        
        <!-- 配置注释生成 -->
        <commentGenerator>
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->
            <property name="suppressAllComments" value="false" />
        </commentGenerator>
        
        <!-- 配置连接数据库 -->
        <jdbcConnection connectionURL="jdbc:mysql://127.0.0.1:3306/shop?serverTimezone=UTC" 
                        driverClass="com.mysql.cj.jdbc.Driver"
                        password="123456" 
                        userId="root"/>
        <!-- 配置实体生成 --> 
        <javaModelGenerator targetPackage="cn.kooun.pojo.table"
                            targetProject="web"/>
        
        <!-- 配置sql映射文件生成 -->    
        <sqlMapGenerator targetPackage="cn.kooun.mapper" 
                         targetProject="web"/>
        
        <!-- 配置数据访问接口类生成  -->
        <javaClientGenerator targetPackage="cn.kooun.mapper"
                             targetProject="web" type="XMLMAPPER" />
        
        <!-- 配置表相关信息 -->    
        <table schema="shop" tableName="u_user"
                domainObjectName="User"
                enableCountByExample="false" 
                enableDeleteByExample="false"
                enableSelectByExample="false" 
                enableUpdateByExample="false">
            <!-- 列映射成属性配置 -->
            <columnOverride column="content" property="content" />
        </table>
    </context>
    
</generatorConfiguration>
二、逆向工程在eclipse中的运行
2.1 将逆向工程插件(jar包)放置在eclipse安装目录下相同的包下,重启eclipse
将逆向工程插件放在eclipse的相同目录下,重启eclipse.jpg
2.2 eclipse中运行
逆向工程的运行.jpg

以上运行成功,会自动生成对应表的pojo类和dao层的mapper类和mapper.xml

eclipse中安装springboot插件
eclipse安装springboot插件.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。