mybatis逆向工程生成相关文件

前面一篇博文中谢了使用插件方式生成mybatis相关文件,下面介绍下使用maven依赖的方式。这里演示使用idea

1. pom.xml配置

<plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <configurationFile>src/main/resources/mybatis-generatorConfig.xml</configurationFile>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.34</version>
                    </dependency>
                </dependencies>
            </plugin>

2.新建mybatis-generatorConfig.xml

在pom.xml配置的

<configurationFile>src/main/resources/mybatis-generatorConfig.xml</configurationFile>

对应目录下新建mybatis-generatorConfig.xml

3.配置mybatis-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>
    <context id="mysqlgenerator" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressAllComments" value="true"/> <!--是否取消注释-->
            <property name="suppressDate" value="true"/> <!--是否生成注释时间戳-->
        </commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/springsecurity?characterEncoding=UTF-8"
                        userId="root"
                        password="299522" />
        <!--指定生成java类型-->
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <javaModelGenerator targetPackage="com.awna.model" targetProject="src/main/java" />

        <sqlMapGenerator targetPackage="mappers" targetProject="src/main/resources" />

        <javaClientGenerator type="XMLMAPPER" targetPackage="com.awna.dao" targetProject="src/main/java" />

        <table tableName="SYS_USER" domainObjectName="SysUser"
            enableCountByExample="false" enableUpdateByExample="false"
               enableSelectByExample="false" enableDeleteByExample="false"
               selectByExampleQueryId="false" >
         <property name="useActualColumnNames" value="false"/>
        </table>
        <table tableName="SYS_ROLE" domainObjectName="SysRole"
               enableCountByExample="false" enableUpdateByExample="false"
               enableSelectByExample="false" enableDeleteByExample="false"
               selectByExampleQueryId="false" >
            <property name="useActualColumnNames" value="false"/>
        </table>
        <table tableName="SYS_ROLE_USER" domainObjectName="SysRoleUser"
               enableCountByExample="false" enableUpdateByExample="false"
               enableSelectByExample="false" enableDeleteByExample="false"
               selectByExampleQueryId="false" >
            <property name="useActualColumnNames" value="false"/>
        </table>
        <table tableName="Sys_permission" domainObjectName="SysPermission"
               enableCountByExample="false" enableUpdateByExample="false"
               enableSelectByExample="false" enableDeleteByExample="false"
               selectByExampleQueryId="false" >
            <property name="useActualColumnNames" value="false"/>
        </table>
        <table tableName="Sys_permission_role" domainObjectName="SysPermissionRole"
               enableCountByExample="false" enableUpdateByExample="false"
               enableSelectByExample="false" enableDeleteByExample="false"
               selectByExampleQueryId="false" >
            <property name="useActualColumnNames" value="false"/>
        </table>
    </context>

</generatorConfiguration>

4.运行逆向工程

首先配置idea
这里写图片描述
运行


想了解更多java相关技术,请关注公众号“JavaEE那些事”

扫描下面二维码,更多技术资料等你来拿
这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值