亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

IDEA插件之mybatisx?插件使用教程

 更新時間:2022年05月01日 09:57:03   作者:o_瓜田李下_o  
這篇文章主要介紹了mybatisx?插件使用教程,包括插件安裝自動生成代碼的相關(guān)知識,本文通過實例圖文相結(jié)合給大家介紹的非常詳細(xì),需要的朋友可以參考下

MybatisX 是一款基于 IDEA 的快速開發(fā)插件,為效率而生。今天給大家介紹下mybatisx 插件使用。

mybatisx 插件使用

官網(wǎng):https://baomidou.com/pages/ba5b24

插件安裝

file ==> preferences ==> plugins:搜索mybatisx,安裝插件

mybatisx 功能:

文件跳轉(zhuǎn):點擊圖標(biāo),可實現(xiàn)mapper接口、對應(yīng)xml之間的互相跳轉(zhuǎn),serverImpl層跳轉(zhuǎn)到注入的mapper接口

代碼自動生成:根據(jù)表自動生成實體類、mapper接口、mapper xml、service、serverImpl類,模板可自定義

mapper方法自動填充:mapper接口中輸入部分方法名,可自動補(bǔ)全代碼,并在對應(yīng)的mapper xml中生成sql語句

自動生成代碼

連接數(shù)據(jù)源

mybatisx-generator 自動生成代碼

說明:實體類的包名、類名,moduler path、base path、package name均可手動編輯

查看自動生成的代碼

文件跳轉(zhuǎn)

mapper接口:點擊圖標(biāo),跳轉(zhuǎn)mapper xml文件

mapper xml:點擊圖標(biāo),跳轉(zhuǎn)到mapper接口

PersonServiceImpl:點擊圖標(biāo),跳轉(zhuǎn)到mapper接口

代碼自動補(bǔ)全

mapper 接口寫出方法名 ==> 右擊 ==> show context actions

generate mybatis sql

mapper xml生成的sql

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.PersonMapper">
    <resultMap id="BaseResultMap" type="com.example.demo.pojo.Person">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="name" column="name" jdbcType="VARCHAR"/>
            <result property="age" column="age" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,name,age
    </sql>
    <!-- mapper xml自動生成的sql語句 -->
    <select id="selectAllByName" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from person
        where
        name = #{name,jdbcType=VARCHAR}
    </select>
</mapper>

自動補(bǔ)全操作示例

自定義模板

mybatisx 模板:可對模板(ftl)進(jìn)行修改、并恢復(fù)默認(rèn)設(shè)置

.meta.xml

<?xml version="1.0" encoding="utf-8" ?>
<templates>
    <template>
        <property name="configName" value="serviceInterface"/>
        <property name="configFile" value="serviceInterface.ftl"/>
        <property name="fileName" value="${domain.fileName}Service"/>
        <property name="suffix" value=".java"/>
        <property name="packageName" value="${domain.basePackage}.service"/>
        <property name="encoding" value="${domain.encoding}"/>
        <property name="basePath" value="${domain.basePath}"/>
    </template>
    <template>
        <property name="configName" value="serviceImpl"/>
        <property name="configFile" value="serviceImpl.ftl"/>
        <property name="fileName" value="${domain.fileName}ServiceImpl"/>
        <property name="suffix" value=".java"/>
        <property name="packageName" value="${domain.basePackage}.service.impl"/>
        <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}.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

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!}
* @createDate ${.now?string('yyyy-MM-dd HH:mm:ss')}
*/
public interface ${mapperInterface.fileName} extends BaseMapper<${tableClass.shortClassName}> {
}

serviceInterface.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}> {
}

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}{
}

mapperXml.ftl

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${mapperInterface.packageName}.${baseInfo.fileName}">
    <resultMap id="BaseResultMap" type="${tableClass.fullClassName}">
        <#list tableClass.pkFields as field>
            <id property="${field.fieldName}" column="${field.columnName}" jdbcType="${field.jdbcType}"/>
        </#list>
        <#list tableClass.baseFields as field>
            <result property="${field.fieldName}" column="${field.columnName}" jdbcType="${field.jdbcType}"/>
        </#list>
    </resultMap>
    <sql id="Base_Column_List">
        <#list tableClass.allFields as field>${field.columnName}<#sep>,<#if field_index%3==2>${"\n        "}</#if></#list>
    </sql>
</mapper>

模版文件恢復(fù)為默認(rèn)設(shè)置

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

相關(guān)文章

最新評論