2021-09-17

tkmapper

导入依赖

请添加图片描述

继承接口

请添加图片描述

请添加图片描述

调用方法

增删改

请添加图片描述

查询

请添加图片描述

请添加图片描述
请添加图片描述

逆向工程

导入插件

请添加图片描述

generatorConfiguration.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>
    <!-- 引入 application.yml -->
    <!--<properties resource="application.yml"/>-->

    <!-- MyBatis3Simple:不生成 Example相关类及方法 ,Mybatis3复杂的 生产Example-->
    <!--MyBatis3模式默认生成的对象将包含很多"by Example"的方法,如果不想生成这些,可以在后续的table元素中配置取消;
    MyBatis3Simple模式默认每个表生成一个实体对象,生成的Mapper接口仅包含必须的5个方法:
    deleteByPrimaryKey、insert、selectByPrimaryKey、selectAll、updateByPrimaryKey。-->
    <context id="Mysql" targetRuntime="Mybatis3" defaultModelType="flat">

        <!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
        <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>

        <!--覆盖生成XML文件-->
        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />

        <!-- 指定生成 Mapper 的继承模板 -->
        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
            <property name="mappers" value="com.demo.utils.generator.TyMapper"/>
        </plugin>

        <!-- 生成 JavaBean 对象重写 toString方法 -->
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>

        <!-- 生成 JavaBean 对象继承 Serializable-->
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>

        <!-- 生成 JavaBean 对象重写 equals 和 hashCode 方法 -->
        <!-- <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" /> -->

        <!-- jdbc 连接配置 -->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://127.0.0.1:3306/demo-example-dev?characterEncoding=utf-8&amp;useSSL=false"
                        userId="root"
                        password="xxxxx">
        </jdbcConnection>

        <!--非必须,类型处理器,在数据库类型和java类型之间的转换控制-->
        <!-- 默认情况下数据库中的 decimal,bigInt 在 Java 对应是 sql 下的 BigDecimal-->
        <javaTypeResolver type="com.demo.utils.generator.JavaTypeResolverImplUtil">
            <property name="forceBigDecimals" value="false"></property>
        </javaTypeResolver>

        <javaModelGenerator targetPackage="com.demo.sys.entity" targetProject="src/main/java">
            <!-- 是否允许子包 -->
            <!--            <property name="enableSubPackages" value="false"/>-->
            <!-- 是否对modal添加构造函数 -->
            <!--            <property name="constructorBased" value="true"/>-->
            <!-- 是否清理从数据库中查询出的字符串左右两边的空白字符 -->
            <!--            <property name="trimStrings" value="true"/>-->
            <!-- 建立modal对象是否不可改变 即生成的modal对象不会有setter方法,只有构造方法 -->
            <!--            <property name="immutable" value="false"/>-->
        </javaModelGenerator>

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

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


        <!-- Mysql 配置 -->
        <!-- <generatedKey column="id" sqlStatement="Mysql" identity="true" /> -->
        <!-- tableName:数据库表名,domainObjectName:生成文件名 ,schema:数据源-->
        <table tableName="sys_user" enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
            <generatedKey column="user_id" sqlStatement="Mysql" identity="true"/>
        </table>
        <table tableName="sys_menu" enableCountByExample="true" enableUpdateByExample="true"
               enableDeleteByExample="true" enableSelectByExample="true"
               selectByExampleQueryId="true">
            <generatedKey column="menu_id" sqlStatement="Mysql" identity="true"/>
        </table>
        <!-- Oracle 配置 -->
        <!-- <generatedKey column="id" sqlStatement="select SEQ_{1}.nextval from dual" identity="false" type="pre"/> -->

    </context>
</generatorConfiguration>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值