欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mybatisX插件的使用及打包成配置

 更新時間:2025年05月12日 11:23:35   作者:錢多多_qdd  
本文主要介紹了mybatisX插件的使用及打包成配置,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

裝mybatisX插件;
idea連接數(shù)據(jù)庫;
點擊mybatisx-generator,設置自己裝mybatisX插件;
idea連接數(shù)據(jù)庫;
點擊mybatisx-generator,設置自己要的包和類;

如果要把自己的配置設置成一個自定義模板:

1、 使用idea鏈接數(shù)據(jù)庫

要的包和類;

如果要把自己的配置設置成一個自定義模板:

一、使用idea鏈接數(shù)據(jù)庫

在這里插入圖片描述

在這里插入圖片描述

二、安裝mybatis-X插件

File–>Settings–>Plugins–>Marketplace,=,搜索MyBatisX–>install

在這里插入圖片描述

三、生成代碼內(nèi)容

3.1 配置本地驅動包

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

3.2 側邊欄打開數(shù)據(jù)庫,選擇要生成代碼的表格,在表名上右擊,點擊MybatisX-Generator

在這里插入圖片描述

3.3 設置類名生成規(guī)則及生成代碼的路徑

路徑的生成按照物理路徑是: module path --》 base path --》base package
(這里注意如果想實體類帶Entity后綴,在extra class suffix一欄填上Entity即可)

在這里插入圖片描述

3.4 生成代碼

在這里插入圖片描述

template:

  • custom-model-swagger:生成實體文件,屬性上會自動增加swagger的相關注解,
  • default-all:生成實體文件、xml文件和dao層接口文件, 默認會生成常用的增刪改查到的方法
  • mybatis-plus3:生成實體文件、xml文件、dao層接口文件、 service層接口文件和service層接口實現(xiàn)文件

3.4.1 mybatis-plus3案例

在這里插入圖片描述

在這里插入圖片描述

3.4.2 效果代碼

實體類:

在這里插入圖片描述

mapper接口:

在這里插入圖片描述

service層:

在這里插入圖片描述

在這里插入圖片描述

xml文件:

在這里插入圖片描述

四、配置文件

4.1 默認的mybatis-plus3模板

模板文件包含:

在這里插入圖片描述

4.1.1 .meta.xml以及xx.ftl概覽

在這里插入圖片描述

從上圖中可以看到,此模板生成了四個文件,加上我們的entity,一共是5個。

serviceInterface.ftl:

在這里插入圖片描述

serviceImpl.ftl:

package ${baseInfo.packageName};

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${tableClass.fullClassName};
import ${serviceInterface.packageName}.${serviceInterface.fileName};
import ${mapperInterface.packageName}.${mapperInterface.fileName};
<#if baseService??&&baseService!="">
import ${baseService};
    <#list baseService?split(".") as simpleName>
        <#if !simpleName_has_next>
            <#assign serviceSimpleName>${simpleName}</#assign>
        </#if>
    </#list>
</#if>
import org.springframework.stereotype.Service;

/**
* @author ${author!}
* @description 針對表【${tableClass.tableName}<#if tableClass.remark?has_content>(${tableClass.remark!})</#if>】的數(shù)據(jù)庫操作Service實現(xiàn)
* @createDate ${.now?string('yyyy-MM-dd HH:mm:ss')}
*/
@Service
public class ${baseInfo.fileName} extends ServiceImpl<${mapperInterface.fileName}, ${tableClass.shortClassName}>
    implements ${serviceInterface.fileName}{

}

mapperInterface.ftl:

package ${mapperInterface.packageName};

import ${tableClass.fullClassName};
<#if tableClass.pkFields??>
    <#list tableClass.pkFields as field><#assign pkName>${field.shortTypeName}</#assign></#list>
</#if>
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* @author ${author!}
* @description 針對表【${tableClass.tableName}<#if tableClass.remark?has_content>(${tableClass.remark!})</#if>】的數(shù)據(jù)庫操作Mapper
* @createDate ${.now?string('yyyy-MM-dd HH:mm:ss')}
* @Entity ${tableClass.fullClassName}
*/
public interface ${mapperInterface.fileName} extends BaseMapper<${tableClass.shortClassName}> {

}

mapperXml.ftl:

在這里插入圖片描述

4.2 我的mybatis-plus3模板

要點:把service改為repository,作為倉儲層,而不是業(yè)務層。

在這里插入圖片描述

.meta.xml:

<?xml version="1.0" encoding="utf-8" ?>
<templates>
    <template>
        <property name="configName" value="repositoryInterface"/>
        <property name="configFile" value="repositoryInterface.ftl"/>
        <property name="fileName" value="${domain.fileName}Repository"/>
        <property name="suffix" value=".java"/>
        <property name="packageName" value="${domain.basePackage}.domain.gateway.db"/>
        <property name="encoding" value="${domain.encoding}"/>
        <property name="basePath" value="${domain.basePath}"/>
    </template>
    <template>
        <property name="configName" value="repositoryImpl"/>
        <property name="configFile" value="repositoryImpl.ftl"/>
        <property name="fileName" value="${domain.fileName}RepositoryImpl"/>
        <property name="suffix" value=".java"/>
        <property name="packageName" value="${domain.basePackage}.infrastructure.repository"/>
        <property name="encoding" value="${domain.encoding}"/>
        <property name="basePath" value="${domain.basePath}"/>
    </template>
    <template>
        <property name="configName" value="mapperInterface"/>
        <property name="configFile" value="mapperInterface.ftl"/>
        <property name="fileName" value="${domain.fileName}Mapper"/>
        <property name="suffix" value=".java"/>
        <property name="packageName" value="${domain.basePackage}.infrastructure.repository.mybatis.mapper"/>
        <property name="encoding" value="${domain.encoding}"/>
        <property name="basePath" value="${domain.basePath}"/>
    </template>
    <template>
        <property name="configName" value="mapperXml"/>
        <property name="configFile" value="mapperXml.ftl"/>
        <property name="fileName" value="${domain.fileName}Mapper"/>
        <property name="suffix" value=".xml"/>
        <property name="packageName" value="mapper"/>
        <property name="encoding" value="${domain.encoding}"/>
        <property name="basePath" value="src/main/resources"/>
    </template>
</templates>

mapperInterface.ftl:略,和4.1相同;

mapperXml.ftl:略,和4.1相同;

repositoryInterface.ftl:

package ${baseInfo.packageName};

import ${tableClass.fullClassName};
<#if baseService??&&baseService!="">
import ${baseService};
    <#list baseService?split(".") as simpleName>
        <#if !simpleName_has_next>
            <#assign serviceSimpleName>${simpleName}</#assign>
        </#if>
    </#list>
</#if>
import com.baomidou.mybatisplus.extension.service.IService;

/**
* @author ${author!}
* @description 針對表【${tableClass.tableName}<#if tableClass.remark?has_content>(${tableClass.remark!})</#if>】的數(shù)據(jù)庫操作Service
* @createDate ${.now?string('yyyy-MM-dd HH:mm:ss')}
*/
public interface ${baseInfo.fileName} extends IService<${tableClass.shortClassName}> {

}

其實和4.1也是一樣的,不同的是.meta.xml里的參數(shù)變了:

在這里插入圖片描述

repositoryImpl.ftl:

package ${baseInfo.packageName};

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${tableClass.fullClassName};
import ${repositoryInterface.packageName}.${repositoryInterface.fileName};
import ${mapperInterface.packageName}.${mapperInterface.fileName};
<#if baseService??&&baseService!="">
import ${baseService};
    <#list baseService?split(".") as simpleName>
        <#if !simpleName_has_next>
            <#assign serviceSimpleName>${simpleName}</#assign>
        </#if>
    </#list>
</#if>
import org.springframework.stereotype.Service;

/**
* @author ${author!}
* @description 針對表【${tableClass.tableName}<#if tableClass.remark?has_content>(${tableClass.remark!})</#if>】的數(shù)據(jù)庫操作Service實現(xiàn)
* @createDate ${.now?string('yyyy-MM-dd HH:mm:ss')}
*/
@Service
public class ${baseInfo.fileName} extends ServiceImpl<${mapperInterface.fileName}, ${tableClass.shortClassName}> implements ${repositoryInterface.fileName}{

}

同上,和4.1也是一樣的,不同的兩點:

  • 是.meta.xml里的參數(shù)變了;
  • import里的導入類全路徑引用變了;

在這里插入圖片描述

在這里插入圖片描述

五、打包配置,一鍵給其他人復用

在這里插入圖片描述

以我的【mybatis-plus3-20230824】為例:

在這里插入圖片描述

其他人把壓縮包解壓到對應的位置即可。

到此這篇關于mybatisX插件的使用及打包成配置的文章就介紹到這了,更多相關mybatisX插件使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • java實戰(zhàn)項目之記賬軟件

    java實戰(zhàn)項目之記賬軟件

    這篇文章主要介紹了java實戰(zhàn)項目之記賬軟件,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-04-04
  • 一篇文章帶你詳解Spring的AOP

    一篇文章帶你詳解Spring的AOP

    這篇文章主要為大家介紹了Spring的AOP,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2022-01-01
  • 聊聊java中引用數(shù)據(jù)類型有哪些

    聊聊java中引用數(shù)據(jù)類型有哪些

    這篇文章主要介紹了java中引用數(shù)據(jù)類型有哪些,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • RabbitMQ交換機與Springboot整合的簡單實現(xiàn)

    RabbitMQ交換機與Springboot整合的簡單實現(xiàn)

    這篇文章主要介紹了RabbitMQ交換機與Springboot整合的簡單實現(xiàn),本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-07-07
  • IDEA MyBatis Plugins自動生成實體類和mapper.xml

    IDEA MyBatis Plugins自動生成實體類和mapper.xml

    這篇文章主要介紹了IDEA MyBatis Plugins自動生成實體類和mapper.xml,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-07-07
  • Java如何實現(xiàn)數(shù)字逆序

    Java如何實現(xiàn)數(shù)字逆序

    這篇文章主要介紹了Java如何實現(xiàn)數(shù)字逆序問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • SpringBoot實現(xiàn)RabbitMQ監(jiān)聽消息的四種方式

    SpringBoot實現(xiàn)RabbitMQ監(jiān)聽消息的四種方式

    本文主要介紹了SpringBoot實現(xiàn)RabbitMQ監(jiān)聽消息的四種方式,包括@RabbitListener,MessageListener接口,MessageListenerAdapter適配器,@RabbitHandler這幾種,感興趣的可以了解一下
    2024-05-05
  • 基于RabbitMQ幾種Exchange 模式詳解

    基于RabbitMQ幾種Exchange 模式詳解

    下面小編就為大家?guī)硪黄赗abbitMQ幾種Exchange 模式詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • Java并發(fā)Lock接口實現(xiàn)示例詳解

    Java并發(fā)Lock接口實現(xiàn)示例詳解

    這篇文章主要為大家介紹了Java并發(fā)Lock接口,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-06-06
  • Java中try、catch的使用方法

    Java中try、catch的使用方法

    這篇文章主要介紹了Java中try、catch的使用方法,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-06-06

最新評論