国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

tk-mybatis使用介紹,springboot整合tk-mybatis、PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún)

這篇具有很好參考價(jià)值的文章主要介紹了tk-mybatis使用介紹,springboot整合tk-mybatis、PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

Mybatis-Plus極大簡(jiǎn)化了我們的開(kāi)發(fā),作為mybatis的增強(qiáng)版,Mybatis-Plus確實(shí)幫我們減少了很多SQL語(yǔ)句的編寫(xiě),通過(guò)其提供的API,可以方便地完成增刪查改操作。但是,其實(shí)除了Mybatis-Plus以外,還有一個(gè)技術(shù)tk-mybatis可以達(dá)到同樣的效果,只不過(guò)隨著MP的興起,tk-mybatis已經(jīng)被漸漸淡忘,就像曾經(jīng)的JSP+Servlet。

因此,為了證明tk-mybatis曾經(jīng)存在過(guò),這篇文章就詳細(xì)介紹一下tk-mybatis的使用方法。

目錄

第一步:準(zhǔn)備數(shù)據(jù)庫(kù)

第二步:創(chuàng)建一個(gè)springboot項(xiàng)目

第三步:添加tk-mybatis的依賴(lài)

第四步:修改配置文件

第五步:創(chuàng)建數(shù)據(jù)庫(kù)表對(duì)應(yīng)的實(shí)體類(lèi)

第六步:持久層接口繼承自Mapper接口

第七步:使用tk-mybatis的API完成crud

擴(kuò)展:使用tk-mybatis整合PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún)

1、添加PageHelper依賴(lài)

2、設(shè)置分頁(yè)攔截器

3、在所有代碼之前開(kāi)啟分頁(yè)


第一步:準(zhǔn)備數(shù)據(jù)庫(kù)

創(chuàng)建數(shù)據(jù)庫(kù)tkmybatis,然后執(zhí)行項(xiàng)目resources目錄下的tkmybatis.sql腳本文件。

tk-mybatis使用介紹,springboot整合tk-mybatis、PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún),mybatis,spring boot,java

第二步:創(chuàng)建一個(gè)springboot項(xiàng)目

本篇文章將創(chuàng)建一個(gè)名為tkmybatis的springboot項(xiàng)目用于演示tkmybatis的使用。

第三步:添加tk-mybatis的依賴(lài)

<dependency>
    <groupId>tk.mybatis</groupId>
    <artifactId>mapper-spring-boot-starter</artifactId>
    <version>1.1.5</version>
</dependency>

項(xiàng)目完整的依賴(lài)如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.9</version>
        <relativePath/>
    </parent>

    <groupId>com.example</groupId>
    <artifactId>tkmybatis</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <java.version>1.8</java.version>
        <mysql.version>8.0.28</mysql.version>
        <druid.version>1.1.21</druid.version>
        <lombok.version>1.18.22</lombok.version>
        <mybatis.version>2.2.2</mybatis.version>
        <tkmybatis.version>1.1.5</tkmybatis.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <!--lombok-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>

        <!--mysql-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!--數(shù)據(jù)庫(kù)連接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>${druid.version}</version>
        </dependency>

        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>${mybatis.version}</version>
        </dependency>

        <!--tk.mybatis-->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <version>${tkmybatis.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

第四步:修改配置文件

在application.yml中配置數(shù)據(jù)源和日志的顯示級(jí)別

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/tkmybatis
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource

logging:
  level:
    springfox: error
    com.example.tkmybatis: debug

第五步:創(chuàng)建數(shù)據(jù)庫(kù)表對(duì)應(yīng)的實(shí)體類(lèi)

package com.example.tkmybatis.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.Id;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 歌曲
 * @author heyunlin
 * @version 1.0
 */
@Data
public class Song implements Serializable {
    private static final long serialVersionUID = 18L;

    @Id
    private String id;

    /**
     * 歌曲名
     */
    private String name;

    /**
     * 歌手
     */
    private String singer;

    /**
     * 描述信息
     */
    private String note;

    /**
     * 最后一次修改時(shí)間
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime lastUpdateTime;
}

第六步:持久層接口繼承自Mapper接口

package com.example.tkmybatis.mapper;

import com.example.tkmybatis.entity.Song;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

/**
 * @author heyunlin
 * @version 1.0
 */
@Repository
public interface SongMapper extends Mapper<Song> {

}

在這點(diǎn)上,其實(shí)和mybatis-plus很像,mybatis-plus里是繼承BaseMapper<T>接口,然后使用BaseMapper<T>接口中預(yù)定義實(shí)現(xiàn)的簡(jiǎn)單crud方法。

但是,tk-mybatis的各個(gè)API在繼承關(guān)系上又和mybatis-plus完全不同,tk-mybatis中,一個(gè)接口中只定義一個(gè)方法(把接口隔離原則體現(xiàn)的淋漓盡致ovo)。

package tk.mybatis.mapper.common;

public interface Mapper<T> extends
        BaseMapper<T>,
        ExampleMapper<T>,
        RowBoundsMapper<T>,
        Marker {

}

可以發(fā)現(xiàn),Mapper接口繼承了很多個(gè)接口BaseMapper、ExampleMapper和RowBoundsMapper,而B(niǎo)aseMapper又繼承了基本的增刪查改的Mapper接口BaseSelectMapper、BaseInsertMapper、BaseUpdateMapper和BaseDeleteMapper。

這幾個(gè)接口又繼承了相應(yīng)的插入、刪除、更新或查詢(xún)的接口,每個(gè)接口中只定義一個(gè)方法

BaseMapper.java

package tk.mybatis.mapper.common;

import tk.mybatis.mapper.common.base.BaseDeleteMapper;
import tk.mybatis.mapper.common.base.BaseInsertMapper;
import tk.mybatis.mapper.common.base.BaseSelectMapper;
import tk.mybatis.mapper.common.base.BaseUpdateMapper;

public interface BaseMapper<T> extends
        BaseSelectMapper<T>,
        BaseInsertMapper<T>,
        BaseUpdateMapper<T>,
        BaseDeleteMapper<T> {

}

BaseSelectMapper.java

package tk.mybatis.mapper.common.base;

import tk.mybatis.mapper.common.base.select.*;

public interface BaseSelectMapper<T> extends
        SelectOneMapper<T>,
        SelectMapper<T>,
        SelectAllMapper<T>,
        SelectCountMapper<T>,
        SelectByPrimaryKeyMapper<T>,
        ExistsWithPrimaryKeyMapper<T> {

}

第七步:使用tk-mybatis的API完成crud

tk-mybatis中兩個(gè)重要的API相關(guān)說(shuō)明:

  • tk.mybatis.mapper.entity.Example
  • tk.mybatis.mapper.entity.Example.Criteria

1、創(chuàng)建Example對(duì)象

2、通過(guò)Example的靜態(tài)方法createCriteria()獲取Criteria對(duì)象

接下來(lái)通過(guò)測(cè)試類(lèi)測(cè)試tkmybatis的API方法

package com.example.tkmybatis;

import com.example.tkmybatis.entity.Song;
import com.example.tkmybatis.mapper.SongMapper;
import com.example.tkmybatis.util.StringUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@SpringBootTest
class TkMybatisTests {

    @Autowired
    private SongMapper songMapper;

    @Test
    void testInsert() {
        Song song = new Song();

        song.setId(StringUtils.uuid());
        song.setName("稻香");
        song.setSinger("周杰倫");

        // 添加
        songMapper.insert(song);
        // 選擇性添加
        // 拼接sql語(yǔ)句時(shí)會(huì)在每個(gè)字段設(shè)置前添加null判斷,只有不為null才設(shè)置到set子句
        songMapper.insertSelective(song);
    }

    @Test
    void testUpdate() {
        Song song = new Song();

        song.setId(StringUtils.uuid());
        song.setName("稻香");
        song.setSinger("周杰倫");

        // 通過(guò)主鍵修改
        songMapper.updateByPrimaryKey(song);
        // 通過(guò)主鍵選擇性修改
        songMapper.updateByPrimaryKeySelective(song);
    }

    @Test
    void testUpdateByExample() {
        Song song = new Song();

        song.setId(StringUtils.uuid());
        song.setName("稻香");
        song.setSinger("周杰倫");

        Example example = new Example(Song.class);
        Example.Criteria criteria = example.createCriteria();

        criteria.andCondition("name = ", song.getName());

        // 通過(guò)Example中設(shè)置的條件修改
        songMapper.updateByExample(song, example);
        // 通過(guò)Example中設(shè)置的條件選擇性地修改
        songMapper.updateByExampleSelective(song, example);
    }

    @Test
    void testSelect() {
        Song song = new Song();

        song.setName("稻香");
        song.setSinger("周杰倫");

        // 根據(jù)song中設(shè)置字段作為條件查詢(xún)條件
        List<Song> select = songMapper.select(song);
        // 根據(jù)主鍵查詢(xún)(也就是@Id注解標(biāo)注的字段)
        Song selectByPrimaryKey = songMapper.selectByPrimaryKey("123");
        // 查詢(xún)?nèi)?        List<Song> selectAll = songMapper.selectAll();
        // 同select()方法,當(dāng)能夠確定查詢(xún)結(jié)果中最多只有一條記錄時(shí)可以使用此方法
        Song selectOne = songMapper.selectOne(song);
        // 根據(jù)song中設(shè)置字段作為條件查詢(xún)條件,返回符合條件的記錄數(shù)
        int selectCount = songMapper.selectCount(song);
    }

    @Test
    void testSelectByExample() {
        Example example = new Example(Song.class);
        Example.Criteria criteria = example.createCriteria();

        example.setOrderByClause("last_update_time");

        criteria.andCondition("name = ", "稻香");
        criteria.andCondition("singer = ", "周杰倫");

        List<Song> list = songMapper.selectByExample(example);
        int count = songMapper.selectCountByExample(example);
    }

}

擴(kuò)展:使用tk-mybatis整合PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún)

和mybatis-plus不同,tk-mybatis并沒(méi)有幫我們實(shí)現(xiàn)分頁(yè)功能,需要整合PageHelper來(lái)實(shí)現(xiàn)分頁(yè)查詢(xún)。

1、添加PageHelper依賴(lài)

<!-- 分頁(yè)插件 -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.1.4</version>
</dependency>

2、設(shè)置分頁(yè)攔截器

package com.example.tkmybatis.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.github.pagehelper.PageInterceptor;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;
import java.util.Properties;

/**
 * Mybatis配置類(lèi)
 * @author heyunlin
 * @version 1.0
 */
@Configuration
@MapperScan("com.example.tkmybatis.mapper")
public class MybatisConfig {
    
    @Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource getDataSource() {
        return DataSourceBuilder.create().type(DruidDataSource.class).build();
    }

    /**
     * 定義創(chuàng)建Session工廠(chǎng)Bean的方法
     * @return SqlSessionFactoryBean
     */
    @Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean() {
        // 定義MyBatis的Session工廠(chǎng)對(duì)象,用于產(chǎn)生MyBatis全局的會(huì)話(huà)工廠(chǎng)
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

        // 設(shè)置數(shù)據(jù)源
        sqlSessionFactoryBean.setDataSource(getDataSource());
        Properties properties = new Properties();

        properties.setProperty("reasonable", "true");
        properties.setProperty("pageSizeZero", "true");
        properties.setProperty("supportMethodsArguments", "true");

        // 創(chuàng)建分頁(yè)攔截器
        PageInterceptor interceptor = new PageInterceptor();
        interceptor.setProperties(properties);

        // 添加分頁(yè)攔截器
        sqlSessionFactoryBean.setPlugins(interceptor);

        return sqlSessionFactoryBean;
    }

}

3、在所有代碼之前開(kāi)啟分頁(yè)

在所有代碼之前添加PageHelper.startPage(int page, int size)方法開(kāi)啟分頁(yè)。例如:

package com.example.tkmybatis;

import com.example.tkmybatis.dto.SongPagerDTO;
import com.example.tkmybatis.entity.Song;
import com.example.tkmybatis.mapper.SongMapper;
import com.example.tkmybatis.util.StringUtils;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.RowBounds;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@SpringBootTest
class TkMybatisTests {

    @Autowired
    private SongMapper songMapper;

    @Test
    void testSelectByPage() {
        // 模擬后臺(tái)傳的參數(shù)
        SongPagerDTO pagerDTO = new SongPagerDTO();
        pagerDTO.setName("愛(ài)");

        PageHelper.startPage(pagerDTO.getPage(), pagerDTO.getRows());

        Example example = new Example(Song.class);
        Example.Criteria criteria = example.createCriteria();

        if (StringUtils.isNotEmpty(pagerDTO.getName())) {
            criteria.andLike("name", "%".concat(pagerDTO.getName()).concat("%"));
        }

        List<Song> list = songMapper.selectByExample(example);
        int count = songMapper.selectCountByExample(example);

        // 封裝查詢(xún)結(jié)果返回
    }

}

整個(gè)項(xiàng)目的結(jié)構(gòu)如下

tk-mybatis使用介紹,springboot整合tk-mybatis、PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún),mybatis,spring boot,java

好了,文章就分享到這里了,文章設(shè)計(jì)代碼已經(jīng)上傳到git倉(cāng)庫(kù),按需獲取

tkmybatis使用詳解案例項(xiàng)目https://gitee.com/he-yunlin/tkmybatis.git文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-655315.html

到了這里,關(guān)于tk-mybatis使用介紹,springboot整合tk-mybatis、PageHelper實(shí)現(xiàn)分頁(yè)查詢(xún)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀(guān)點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Spring與Mybatis整合&&aop整合pageHelper分頁(yè)插件

    Spring與Mybatis整合&&aop整合pageHelper分頁(yè)插件

    Spring與MyBatis整合 的意義在于提供了一種結(jié)合優(yōu)勢(shì)的方式,以便更好地 開(kāi)發(fā)和管理持久層(數(shù)據(jù)庫(kù)訪(fǎng)問(wèn))代碼 。 這里也是總結(jié)了幾點(diǎn)主要意義 簡(jiǎn)化配置:Spring與MyBatis整合后,可以通過(guò)Spring的配置文件來(lái)管理和配置MyBatis的相關(guān)配置,例如數(shù)據(jù)源、事務(wù)管理等,而不需要額外

    2024年02月11日
    瀏覽(158)
  • MyBatis與Spring整合以及AOP和PageHelper分頁(yè)插件整合

    MyBatis與Spring整合以及AOP和PageHelper分頁(yè)插件整合

    目錄 前言 一、MyBatis與Spring整合的好處以及兩者之間的關(guān)系 1.好處 2.關(guān)系 ?二、MyBatis和Spring集成 1.導(dǎo)入pom.xml 2.編寫(xiě)配置文件? 3.利用mybatis逆向工程生成模型層代碼 三、常用注解 ?四、AOP整合pageHelper分頁(yè)插件 創(chuàng)建一個(gè)切面 測(cè)試 MyBatis是一個(gè)開(kāi)源的持久層框架,而Spring是一個(gè)

    2024年02月11日
    瀏覽(22)
  • Spring與MyBatis集成 AOP整合PageHelper插件

    Spring與MyBatis集成 AOP整合PageHelper插件

    目錄 1.什么是集成? 2.Spring與MyBatis集成 3.Spring與MyBatis集成的基本配置 4.AOP整合PageHelper插件 集成是指將不同的組件、框架或系統(tǒng)整合到一起,使它們可以協(xié)同工作、相互調(diào)用、共享資源等。通過(guò)集成,可以實(shí)現(xiàn)不同組件之間的功能互補(bǔ)、數(shù)據(jù)交互、業(yè)務(wù)流程整合等。 在軟件

    2024年02月10日
    瀏覽(23)
  • Spring 與【MyBatis 】和【 pageHelper分頁(yè)插件 】整合

    Spring 與【MyBatis 】和【 pageHelper分頁(yè)插件 】整合

    目錄 一、Spring整合MyBatis 1. 導(dǎo)入pom依賴(lài) 2. 利用mybatis逆向工程生成模型層層代碼 3. 編寫(xiě)配置文件 4. 注解式開(kāi)發(fā) 5. 編寫(xiě)Junit測(cè)試類(lèi) 二、AOP整合pageHelper分頁(yè)插件 1. 創(chuàng)建一個(gè)AOP切面 2. @Around(\\\"execution(* *..*xxx.*xxx(..))\\\")?表達(dá)式解析 3. 編寫(xiě)測(cè)試 1.1 添加spring相關(guān)依賴(lài)(5.0.2.RELEASE) ????

    2024年02月11日
    瀏覽(20)
  • MyBatis與Spring集成&常用注解以及AOP和PageHelper分頁(yè)插件整合

    MyBatis與Spring集成&常用注解以及AOP和PageHelper分頁(yè)插件整合

    目錄 前言 一、MyBatis與Spring整合的好處以及兩者之間的關(guān)系 1.好處 2.關(guān)系 ?二、MyBatis和Spring集成 1.導(dǎo)入pom.xml 2.編寫(xiě)配置文件? 3.利用mybatis逆向工程生成模型層代碼 三、常用注解 ?四、AOP整合pageHelper分頁(yè)插件 創(chuàng)建一個(gè)切面 測(cè)試 MyBatis是一個(gè)開(kāi)源的持久層框架,而Spring是一個(gè)

    2024年02月07日
    瀏覽(27)
  • SpringBoot第26講:SpringBoot集成MySQL - MyBatis PageHelper分頁(yè)

    前文中,我們展示了Spring Boot與MyBatis的集成,但是沒(méi)有展示分頁(yè)實(shí)現(xiàn)。本文是SpringBoot第26講,專(zhuān)門(mén)介紹分頁(yè)相關(guān)知識(shí)體系和基于MyBatis的 物理分頁(yè)P(yáng)ageHelper

    2024年02月13日
    瀏覽(23)
  • 【SpringBoot】MyBatis與MyBatis-Plus分頁(yè)查詢(xún) & github中的PageHelper

    【SpringBoot】MyBatis與MyBatis-Plus分頁(yè)查詢(xún) & github中的PageHelper

    ??????? 筆者寫(xiě)這篇博客是因?yàn)榻谟龅降年P(guān)于兩者之間的分頁(yè)代碼差距,其實(shí)之前也遇見(jiàn)過(guò)但是沒(méi)有去整理這篇博客,但由于還是被困擾了小一會(huì)兒時(shí)間,所以還是需要 加深記憶 。其實(shí)會(huì)看前后端傳參解決這個(gè)問(wèn)題很快、不麻煩。關(guān)于這兩個(gè)框架的分頁(yè)代碼問(wèn)題主要就

    2024年02月03日
    瀏覽(24)
  • SpringBoot(整合MyBatis + MyBatis-Plus + MyBatisX插件使用)

    SpringBoot(整合MyBatis + MyBatis-Plus + MyBatisX插件使用)

    1.需求分析 2.數(shù)據(jù)庫(kù)表設(shè)計(jì) 3.數(shù)據(jù)庫(kù)環(huán)境配置 1.新建maven項(xiàng)目 2.pom.xml 引入依賴(lài) 3.application.yml 配置數(shù)據(jù)源 數(shù)據(jù)庫(kù)名 用戶(hù)名 密碼 驅(qū)動(dòng)是mysql8的(因?yàn)樯厦媸褂昧税姹局俨茫?4.Application.java 編寫(xiě)啟動(dòng)類(lèi) 5.測(cè)試 6.配置類(lèi)切換druid數(shù)據(jù)源 7.測(cè)試數(shù)據(jù)源是否成功切換 4.Mybatis基礎(chǔ)配置 1

    2024年03月20日
    瀏覽(30)
  • SpringBoot整合Druid、Mybatis、MybatisPlus以及MybatisPlus的使用

    SpringBoot整合Druid、Mybatis、MybatisPlus以及MybatisPlus的使用

    1)引入jar包 2)在application.yml中 注意:?initialization-mode: always 第一次用過(guò)之后注釋掉,或者將其改成never 3).啟動(dòng)項(xiàng)目,訪(fǎng)問(wèn):http://127.0.0.1:8080/druid/? ?? ? ? ?用戶(hù)名:admin/密碼:123456(在配置文件中有) ps:還記得mybatis中的sqlSessionFactory要傳入一個(gè)dataSource嗎?所以我們先學(xué)習(xí)

    2024年02月12日
    瀏覽(27)
  • EMQ的介紹及整合SpringBoot的使用

    EMQ的介紹及整合SpringBoot的使用

    首先先了解一下底層的協(xié)議: 1. MQTT MQTT(Message Queuing Telemetry Transport,消息隊(duì)列遙測(cè)傳輸協(xié)議),是一種基于發(fā)布/訂閱 (publish/subscribe)模式的\\\" 輕量級(jí) \\\"通訊協(xié)議,該協(xié)議構(gòu)建于TCP/IP協(xié)議上,由IBM在1999年發(fā)布。 MQTT最大優(yōu)點(diǎn)在于,可以 以極少的代碼和有限的帶寬,為連接遠(yuǎn)程

    2024年02月11日
    瀏覽(13)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包