最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

如果要把自己的配置設(shè)置成一個(gè)自定義模板:

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

要的包和類;

如果要把自己的配置設(shè)置成一個(gè)自定義模板:

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

在這里插入圖片描述

在這里插入圖片描述

二、安裝mybatis-X插件

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

在這里插入圖片描述

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

3.1 配置本地驅(qū)動(dòng)包

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

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

在這里插入圖片描述

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

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

在這里插入圖片描述

3.4 生成代碼

在這里插入圖片描述

template:

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

3.4.1 mybatis-plus3案例

在這里插入圖片描述

在這里插入圖片描述

3.4.2 效果代碼

實(shí)體類:

在這里插入圖片描述

mapper接口:

在這里插入圖片描述

service層:

在這里插入圖片描述

在這里插入圖片描述

xml文件:

在這里插入圖片描述

四、配置文件

4.1 默認(rèn)的mybatis-plus3模板

模板文件包含:

在這里插入圖片描述

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

在這里插入圖片描述

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

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 針對(duì)表【${tableClass.tableName}<#if tableClass.remark?has_content>(${tableClass.remark!})</#if>】的數(shù)據(jù)庫操作Service實(shí)現(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 針對(duì)表【${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模板

要點(diǎn):把service改為repository,作為倉儲(chǔ)層,而不是業(yè)務(wù)層。

在這里插入圖片描述

.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 針對(duì)表【${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}> {

}

其實(shí)和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 針對(duì)表【${tableClass.tableName}<#if tableClass.remark?has_content>(${tableClass.remark!})</#if>】的數(shù)據(jù)庫操作Service實(shí)現(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也是一樣的,不同的兩點(diǎn):

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

在這里插入圖片描述

在這里插入圖片描述

五、打包配置,一鍵給其他人復(fù)用

在這里插入圖片描述

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

在這里插入圖片描述

其他人把壓縮包解壓到對(duì)應(yīng)的位置即可。

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

相關(guān)文章

  • Spring Cloud 優(yōu)雅下線以及灰度發(fā)布實(shí)現(xiàn)

    Spring Cloud 優(yōu)雅下線以及灰度發(fā)布實(shí)現(xiàn)

    這篇文章主要介紹了Spring Cloud 優(yōu)雅下線以及灰度發(fā)布實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • java的時(shí)間類匯總(齊全)

    java的時(shí)間類匯總(齊全)

    這篇文章主要介紹了java的時(shí)間類匯總(齊全),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2022-09-09
  • 詳解MyBatis-Plus Wrapper條件構(gòu)造器查詢大全

    詳解MyBatis-Plus Wrapper條件構(gòu)造器查詢大全

    這篇文章主要介紹了詳解MyBatis-Plus Wrapper條件構(gòu)造器查詢大全,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • mybatis中的if-test判斷解讀

    mybatis中的if-test判斷解讀

    在使用MyBatis進(jìn)行條件判斷時(shí),如果條件中涉及到字符與數(shù)字的比較,需要特別注意比較方式,例如,在<if>標(biāo)簽中,比較數(shù)字“1”時(shí),應(yīng)將其寫在雙引號(hào)中,或者使用.toString()方法,避免直接使用字符'1'進(jìn)行比較
    2024-11-11
  • 若依框架多數(shù)據(jù)源切換方式

    若依框架多數(shù)據(jù)源切換方式

    這篇文章主要介紹了若依框架多數(shù)據(jù)源切換方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Java Collection集合iterator方法解析

    Java Collection集合iterator方法解析

    這篇文章主要介紹了Java Collection集合iterator方法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-01-01
  • Spring異常實(shí)現(xiàn)統(tǒng)一處理的方法

    Spring異常實(shí)現(xiàn)統(tǒng)一處理的方法

    這篇文章主要介紹了Spring異常實(shí)現(xiàn)統(tǒng)一處理的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-12-12
  • SpringBoot中@ComponentScan注解過濾排除不加載某個(gè)類的3種方法

    SpringBoot中@ComponentScan注解過濾排除不加載某個(gè)類的3種方法

    這篇文章主要給大家介紹了關(guān)于SpringBoot中@ComponentScan注解過濾排除不加載某個(gè)類的3種方法,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用SpringBoot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2023-07-07
  • Java實(shí)現(xiàn)對(duì)字符串中的數(shù)值進(jìn)行排序操作示例

    Java實(shí)現(xiàn)對(duì)字符串中的數(shù)值進(jìn)行排序操作示例

    這篇文章主要介紹了Java實(shí)現(xiàn)對(duì)字符串中的數(shù)值進(jìn)行排序操作,涉及java字符串與數(shù)組的相互轉(zhuǎn)換以及數(shù)組排序相關(guān)操作技巧,需要的朋友可以參考下
    2018-05-05
  • java時(shí)間和字符串之間相互轉(zhuǎn)換幾種方法

    java時(shí)間和字符串之間相互轉(zhuǎn)換幾種方法

    這篇文章主要介紹了java時(shí)間和字符串之間相互轉(zhuǎn)換的幾種方法,還詳細(xì)解釋了DateTimeFormatter的三種解析模式,并比較了yyyy和uuuu在嚴(yán)格模式下的區(qū)別,需要的朋友可以參考下
    2025-03-03

最新評(píng)論

怀宁县| 通山县| 饶河县| 阿尔山市| 绥棱县| 西充县| 鹤峰县| 永顺县| 潮安县| 修武县| 泰顺县| 东安县| 承德市| 金昌市| 开平市| 天峻县| 沭阳县| 隆安县| 栖霞市| 连南| 沭阳县| 德保县| 织金县| 含山县| 柞水县| 麦盖提县| 兴安县| 晴隆县| 屏山县| 汾西县| 溧水县| 易门县| 榆社县| 宜兰县| 崇信县| 桐乡市| 景宁| 京山县| 成安县| 宝兴县| 竹山县|