Spring Boot整合MyBatis Plus连接数据库

SpringBoot整合MybatisPlus(详细版) ​MybatisPlus是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。它继承了 MyBatis 的所有特性,并且加入了强大的功能,例如自动填充、逻辑删除、乐观锁、性能分析等。 阅读详情

GitHub:SpringBootDemo
Gitee:SpringBootDemo
微信公众号:在这里插入图片描述

在 Spring Boot整合MyBatis连接数据库 这篇文章中,我们已经可以使用Spring Boot整合MyBatis来连接数据库,但随着使用,我们发现,MyBatis还是稍微有点复杂,那有没有更加简单的方式来操作数据库呢,我们惊奇的发现了MyBatis Plus。

0 开发环境

  • JDK:1.8
  • Spring Boot:2.1.1.RELEASE
  • MySQL:5.7.13

1 引入依赖

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.4</version>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>

<!--lombok-->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.30</version>
    <scope>provided</scope>
</dependency>

2 引入数据源

application.yml 增加如下配置信息

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=GMT%2B8
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver
#
mybatis-plus:
  mapper-locations: classpath:mapper/*.xml                #对应mapper映射xml文件所在路径
  type-aliases-package: cn.wbnull.springbootdemo.entity   #对应实体类路径

3 测试

3.1 新建数据库表

CREATE SCHEMA `test` DEFAULT CHARACTER SET utf8mb4 ;

CREATE TABLE `test`.`user` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`));

INSERT INTO `test`.`user` (`name`) VALUES ('张三');
INSERT INTO `test`.`user` (`name`) VALUES ('李四');
INSERT INTO `test`.`user` (`name`) VALUES ('王五');
INSERT INTO `test`.`user` (`name`) VALUES ('周六');

3.2 创建实体类

package cn.wbnull.springbootdemo.entity;

import lombok.Data;

@Data
public class User {

    private int id;
    private String name;
}

3.3 创建Mapper

package cn.wbnull.springbootdemo.mapper;

import cn.wbnull.springbootdemo.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper extends BaseMapper<User> {

}

3.4 创建映射文件

在 resources 目录下新建 mapper 文件夹,用于存放MyBatis Plus映射文件

<?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="cn.wbnull.springbootdemo.mapper.UserMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.wbnull.springbootdemo.entity.User">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, name
    </sql>
</mapper>

3.5 创建Service

package cn.wbnull.springbootdemo.service;

import cn.wbnull.springbootdemo.entity.User;
import cn.wbnull.springbootdemo.mapper.UserMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public String add(String name) {
        User user = new User();
        user.setName(name);

        userMapper.insert(user);

        return "操作成功";
    }

    public List<User> query() {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();

        return userMapper.selectList(queryWrapper);
    }

    public String update(int id, String name) {
        LambdaUpdateWrapper<User> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(User::getName, name);
        updateWrapper.eq(User::getId, id);

        userMapper.update(updateWrapper);

        return "操作成功";
    }

    public String delete(int id) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getId, id);

        userMapper.delete(queryWrapper);

        return "操作成功";
    }
}

3.6 创建Controller

package cn.wbnull.springbootdemo.controller;

import cn.wbnull.springbootdemo.entity.User;
import cn.wbnull.springbootdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    public UserService userService;

    @PostMapping(value = "add")
    public String add(@RequestParam(value = "name") String name) {
        return userService.add(name);
    }

    @PostMapping(value = "query")
    public List<User> query() {
        return userService.query();
    }

    @PostMapping(value = "update")
    public String update(@RequestParam(value = "id") int id, @RequestParam(value = "name") String name) {
        return userService.update(id, name);
    }

    @PostMapping(value = "delete")
    public String delete(@RequestParam(value = "id") int id) {
        return userService.delete(id);
    }
}

3.7 项目启动类

增加@MapperScan,扫描mapper

package cn.wbnull.springbootdemo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("cn.wbnull.springbootdemo.mapper")
public class MybatisPlusApplication {

    public static void main(String[] args) {
        SpringApplication.run(MybatisPlusApplication.class, args);
    }
}

3.8 测试

使用Postman进行测试,输出结果如下

3.8.1 select

在这里插入图片描述

3.8.2 insert

在这里插入图片描述

我们查下数据库,并再用postman请求
在这里插入图片描述
在这里插入图片描述

3.8.3 update

在这里插入图片描述

数据库中成功更新
在这里插入图片描述

3.8.4 delete

在这里插入图片描述

数据库中成功删除
在这里插入图片描述
截至这里,Spring Boot已经成功整合MyBatis Plus并连接上了数据库,且测试正常。

对比发现,我们使用LambdaQueryWrapper来操作数据库会特别方便,

并且,在我们实际开发中,如果存在大量数据库表,我们依旧可以使用Generator来自动生成代码

4 条件构造器 QueryWrapper

上面 3.5 中,我们创建的Service类中,使用了QueryWrapper简化SQL,其基本用法可参考官方文档:https://baomidou.com/pages/10c804/

以下简单整理可供参考

函数名说明例子
allEq全部eq(或个别isNull)allEq({id:1,name:“老王”,age:null})--->id = 1 and name = ‘老王’ and age is null
allEq({id:1,name:“老王”,age:null}, false)--->id = 1 and name = ‘老王’
eq等于 =eq(“name”, “老王”)--->name = ‘老王’
ne不等于 <>ne(“name”, “老王”)--->name <> ‘老王’
gt大于 >gt(“age”, 18)--->age > 18
ge大于等于 >=ge(“age”, 18)--->age >= 18
lt小于 <lt(“age”, 18)--->age < 18
le小于等于 <=le(“age”, 18)--->age <= 18
betweenBETWEEN 值1 AND 值2between(“age”, 18, 30)--->age between 18 and 30
notBetweenNOT BETWEEN 值1 AND 值2notBetween(“age”, 18, 30)--->age not between 18 and 30
likeLIKE ‘%值%’like(“name”, “王”)--->name like ‘%王%’
notLikeNOT LIKE ‘%值%’notLike(“name”, “王”)--->name not like ‘%王%’
likeLeftLIKE ‘%值’likeLeft(“name”, “王”)--->name like ‘%王’
likeRightLIKE ‘值%’likeRight(“name”, “王”)--->name like ‘王%’
notLikeLeftNOT LIKE ‘%值’notLikeLeft(“name”, “王”)--->name not like ‘%王’
notLikeRightNOT LIKE ‘值%’notLikeRight(“name”, “王”)--->name not like ‘王%’
isNull字段 IS NULLisNull(“name”)--->name is null
isNotNull字段 IS NOT NULLisNotNull(“name”)--->name is not null
in字段 IN (value.get(0), value.get(1), …)
字段 IN (v0, v1, …)
in(“age”,{1,2,3})--->age in (1,2,3)
in(“age”, 1, 2, 3)--->age in (1,2,3)
notIn字段 NOT IN (value.get(0), value.get(1), …)
NOT IN (v0, v1, …)
notIn(“age”,{1,2,3})--->age not in (1,2,3)
notIn(“age”, 1, 2, 3)--->age not in (1,2,3)
inSql字段 IN ( sql语句 )inSql(“age”, “1,2,3,4,5,6”)--->age in (1,2,3,4,5,6)
inSql(“id”, “select id from table where id < 3”)--->id in (select id from table where id < 3)
notInSql字段 NOT IN ( sql语句 )notInSql(“age”, “1,2,3,4,5,6”)--->age not in (1,2,3,4,5,6)
notInSql(“id”, “select id from table where id < 3”)--->id not in (select id from table where id < 3)
groupBy分组:GROUP BY 字段, …groupBy(“id”, “name”)--->group by id,name
orderByAsc排序:ORDER BY 字段, … ASCorderByAsc(“id”, “name”)--->order by id ASC,name ASC
orderByDesc排序:ORDER BY 字段, … DESCorderByDesc(“id”, “name”)--->order by id DESC,name DESC
orderBy排序:ORDER BY 字段, …orderBy(true, true, “id”, “name”)--->order by id ASC,name ASC
havingHAVING ( sql语句 )having(“sum(age) > 10”)--->having sum(age) > 10
having(“sum(age) > {0}”, 11)--->having sum(age) > 11
funcfunc 方法(主要方便在出现if…else下调用不同方法能不断链)func(i -> if(true) {i.eq(“id”, 1)} else {i.ne(“id”, 1)})
or拼接 OReq(“id”,1).or().eq(“name”,“老王”)--->id = 1 or name = ‘老王’
or(i -> i.eq(“name”, “李白”).ne(“status”, “活着”))--->or (name = ‘李白’ and status <> ‘活着’)
andAND 嵌套and(i -> i.eq(“name”, “李白”).ne(“status”, “活着”))--->and (name = ‘李白’ and status <> ‘活着’)
nested正常嵌套 不带 AND 或者 ORnested(i -> i.eq(“name”, “李白”).ne(“status”, “活着”))--->(name = ‘李白’ and status <> ‘活着’)
apply拼接 sqlapply(“id = 1”)--->id = 1
apply(“date_format(dateColumn,‘%Y-%m-%d’) = ‘2008-08-08’”)--->date_format(dateColumn,‘%Y-%m-%d’) = ‘2008-08-08’“)
apply(“date_format(dateColumn,‘%Y-%m-%d’) = {0}”, “2008-08-08”)--->date_format(dateColumn,‘%Y-%m-%d’) = ‘2008-08-08’”)
last无视优化规则直接拼接到 sql 的最后last(“limit 1”)
exists拼接 EXISTS ( sql语句 )exists(“select id from table where age = 1”)--->exists (select id from table where age = 1)
notExists拼接 NOT EXISTS ( sql语句 )notExists(“select id from table where age = 1”)--->not exists (select id from table where age = 1)
QueryWrapper
select设置查询字段select(“id”, “name”, “age”)
select(i -> i.getProperty().startsWith(“test”))
UpdateWrapper
setSQL SET 字段set(“name”, “老李头”)
set(“name”, “”)--->数据库字段值变为空字符串
set(“name”, null)--->数据库字段值变为null
setSql设置 SET 部分 SQLsetSql(“name = ‘老李头’”)

5 代码生成器

5.1 引入依赖

<!-- 代码生成器 -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-generator</artifactId>
    <version>3.5.4</version>
</dependency>

<!-- 模板引擎 -->
<dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity-engine-core</artifactId>
    <version>2.3</version>
</dependency>

5.2 新建代码生成器类

代码生成器所有配置可参考官方文档:https://baomidou.com/pages/981406/

package cn.wbnull.springbootdemo.mybatis;

import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.rules.DateType;

import java.util.Collections;
import java.util.Scanner;

public class MybatisPlusGenerator {

    private static final String URL = "jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=GMT%2B8";
    private static final String USERNAME = "root";
    private static final String PASSWORD = "root";

    private static final String PACKAGE_PATH = System.getProperty("user.dir") + "/spring-boot-mybatis-plus/src/main/java";
    private static final String RESOURCES_MAPPER_PATH = System.getProperty("user.dir") + "/spring-boot-mybatis-plus/src/main/resources/mapper/";

    public static void main(String[] args) {
        DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder(URL, USERNAME, PASSWORD)
                .build();

        AutoGenerator autoGenerator = new AutoGenerator(dataSourceConfig);
        autoGenerator.global(globalConfig());
        autoGenerator.packageInfo(packageConfig());
        autoGenerator.strategy(strategyConfig());

        autoGenerator.execute();
    }

    private static GlobalConfig globalConfig() {
        return new GlobalConfig.Builder()
                .outputDir(PACKAGE_PATH)
                .author("null")
                .dateType(DateType.TIME_PACK)
                .commentDate("yyyy-MM-dd")
                .disableOpenDir()
                .build();
    }

    private static PackageConfig packageConfig() {
        return new PackageConfig.Builder()
                .parent("cn.wbnull.springbootdemo")
                .pathInfo(Collections.singletonMap(OutputFile.xml, RESOURCES_MAPPER_PATH))
                .build();
    }

    private static StrategyConfig strategyConfig() {
        return new StrategyConfig.Builder()
                .addInclude(scanner().split(","))
                .mapperBuilder()
                .enableBaseResultMap()
                .enableBaseColumnList()
                .entityBuilder()
                .enableLombok()
                .enableTableFieldAnnotation()
                .build();
    }

    public static String scanner() {
        Scanner scanner = new Scanner(System.in);
        String hint = "请输入数据库表名,多个表名使用英文逗号分隔:";
        System.out.println(hint);
        if (scanner.hasNext()) {
            String ipt = scanner.next();
            if (ipt != null && ipt.length() > 0) {
                return ipt;
            }
        }

        throw new MybatisPlusException("请输入正确的数据库表名");
    }
}

5.3 测试

5.3.1 新建数据库表

我们先新建一个数据库表,便于一会测试自动生成代码

CREATE TABLE `test`.`user_info` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `userCode` VARCHAR(20) NOT NULL,
  `userName` VARCHAR(45) NULL,
  `password` VARCHAR(40) NOT NULL,
  PRIMARY KEY (`id`));

5.3.2 测试

运行MybatisPlusGenerator,输入需要生成的表名
在这里插入图片描述
文件生成完成
在这里插入图片描述

生成文件如下
在这里插入图片描述
这样,对于大量的数据库表,我们就可以使用Generator来生成基本的代码,然后自己再添加其他所需要的代码即可。


优快云:https://blog.youkuaiyun.com/dkbnull/article/details/136331111
微信:https://mp.weixin.qq.com/s/ZJTKX_gmn6ffsY7hNrspHQ
知乎:https://zhuanlan.zhihu.com/p/684251625


springboot+mybatis+mysql最简单实例 在第一步:新建一个工程 下面一页,直接点finish,就行了。 第二步,编辑pom.xml文件,因为我一开始就选了mybatis和mysql,所以里面已经有了这两项依赖 我这里另外添加了一个mybatis自动生成的插件。 <plugin> <groupId>org.mybatis.generator</groupId> <artifactId&... 阅读详情

相关推荐

Spring Boot整合MybatisPlus和Druid

在Java中,我比较ORM熟悉的只有Hibernate和Mybatis,其他的并未实践使用过,在这二者之间我更喜欢Mybatis,因为它精简、灵活(毕竟我是上年纪的程序员,喜欢自己写SQL)。刚才有提到Mybatis,但是这里的重点是介绍Mybatis-Plus,它是Mybatis的增强版,如果要了解Mybatis的细节的话请点击这里。据MyBatis-Plus官网介绍,MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效

Moonxiyue的博客 3071

SpringBoot集成MyBatis-plus

MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。说明:QueryWrapper(LambdaQueryWrapper) 和 UpdateWrapper(LambdaUpdateWrapper) 的父类用于生成 sql 的 where 条件, entity 属性也用于生成 sql 的 where 条件。

qq_43548590的博客 9407

SpringBoot第27讲:SpringBoot集成MySQL - MyBatis 多个数据源

本文是Springboot第27讲,主要讲解哪些场景会使用多个数据源以及哪些场景会需要多个数据源的动态切换呢?本文主要介绍上述场景及SpringBoot+MyBatis实现多个数据源的方案和示例

Jet_qi的博客 4098

Mybatis-Plus操作数据库

mybatis-Plus使用分装方法和条件构造器对数据库进行操作 在 .XML 文件对数据库进行单表操作、多表操作

cxy_ydj的博客 5565

搭建Spring Boot整合Mybatis-plus的Java应用

Spring Boot是一个流行的Java框架,它简化了基于Java的应用程序的开发过程。Mybatis-plus是一个基于MyBatis的增强工具,它提供了许多便利的功能,帮助我们更轻松地与数据库交互。本文将介绍如何搭建一个Spring Boot应用程序,并整合Mybatis-plus来实现数据库操作。现在,我们已经完成了Spring Boot整合Mybatis-plus的搭建过程。如果有任何问题,请随时提问。本文介绍了如何使用Spring Boot整合Mybatis-plus来搭建Java应用程序。

TechWhiz的博客 185

使用Spring Boot和MyBatis-Plus进行MySQL数据库的整合

选择所需的项目元数据,如项目名称、描述、包名等,并选择适当的Spring Boot版本。在后端开发中,Spring Boot和MyBatis-Plus是常用的框架,用于快速构建可靠的Java应用程序。本文将介绍如何使用Spring Boot和MyBatis-Plus来整合MySQL数据库,并提供相应的源代码示例。至此,我们已经完成了使用Spring Boot和MyBatis-Plus整合MySQL数据库的过程。通过以上步骤,我们可以轻松地进行数据库操作,并且能够快速开发出可靠的后端应用程序。

AnHaskell的博客 191

spring boot的使用入门-使用Druid连接池整合Mybatis-Plus连接Mysql数据库

使用Druid连接池整合Mybatis-Plus1、添加依赖2、修改application.properties配置文件3、Druid 部分代码1 DruidConfiguration 配置类4、Mybatis-Plus部分5、其他部分代码ModelMapper 和 Mapper.xmlService 和 ServiceImplController6、工程结构图7、测试发送请求druid管理界面8...

only3c的博客 6795

WRF移动嵌套结合伏羲模型与CFD(PALM)高精度多尺度降尺度分析研究

WRF移动嵌套(Moving Nesting):动态调整高分辨率嵌套网格位置,追踪天气系统(如台风、强对流系统)以提高局地预报精度。伏羲(Fuxi)模型:国产数值模式,提供对WRF模拟的初始及边界条件优化。CFD(Computational Fluid Dynamics)PALM模型:精细化局地流场、湍流、温度分布。

m0_57411304的博客 1711

druid连接池mysql5.7_Spring Boot 使用Druid连接池整合Mybatis-Plus连接Mysql数据库

一、连接池在普通的数据库访问程序中,客户程序得到的连接对象是物理连接,调用连接对象的close()方法将关闭连接,而采用连接池技术,客户程序得到的连接对象是连接池中物理连接的一个句柄,调用连接对象的close()方法,物理连接并没有关闭,数据源的实现只是删除了客户程序中的连接对象和池中的连接对象之间的联系。二、连接池框架比较目前常用的连接池框架主要有c3p0、dbcp、proxool、druid。...

weixin_35572715的博客 1241

最新Win10离线安装.NET Framework 3.5的方法(附离线包2022/3/22)

win10 .net framework 3.5离线安装

别告诉我有Bug 27万+

在Mac下配置用VSCode编写C/C++程序的环境

前言    最近需要编写一些C/C++程序,由于体量都不是很大所以想要追求一个轻量化的编辑和编译环境,于是想起了在Dock栏吃灰的VSCode。通过查找资料,包括VSCode的官方文档,最终配置实现了Mac下基于VSCode的C/C++编辑环境搭建。 正文    在配置环境之前先检查一下机器上都安装了什么C++编译器,通过以下两条命令可以查看是否安装了g++/clang编译器,本人两种编...

Kalikali的专栏 5万+

配置Spring-Boot整合MyBatis plus并且连接Oracle数据库

1、创建项目前的准备 需要准备好java的jdk1.8版本或者jdk8版本,其他版本不太清楚。 2、创建项目 3、环境配置 1、不需要的包先删掉 将以下的包删掉 删完之后是这样子的 2、pom.xml的配置 <!-- https://mvnrepository.com/artifact/cn.easyproject/orai18n --> <dependency> <groupId>cn.easyproject</groupId> &l

纳支猫的博客 1万+

工创赛智能搬运小车实战:视觉定位、底盘控制与RTOS调度

智能搬运系统是嵌入式控制与机器视觉融合的典型工程实践,其核心在于视觉定位精度、运动控制稳定性与实时任务调度能力。在有限算力(如STM32H7)、低功耗约束和结构化场景下,传统CV方法(如FAST+RANSAC)比轻量级深度学习更具鲁棒性与实时性;而底盘控制需穿透PID表层,直击死区补偿、编码器硬件滤波与负载自适应等物理层细节;RTOS则不是炫技工具,而是保障多模块时序确定性的刚需——尤其在视觉-控制-执行强耦合链路中,任务优先级、事件组通信与栈安全直接影响系统存活。本文聚焦全国大学生工程训练竞赛(工创赛)真

weixin_29194693的博客 266

JAVAFX 使用mybatis-plus整合sqlite 操作数据库,保存成功,但数据库没有数据

一、问题描述 sqlite 操作数据库,保存成功,但数据库没有数据,在代码中有查询出了数据,关闭项目,等段时间,启动项目,代码查询数据,数据又不见了。。 最近一直在搞JAVAFX,开发了个工具,用spring boot整合了mybatis-plus+sqlite3,保存数据一直有问题,mybatis-plus保存成功,但数据库一直没有没有内容,但是在mybatis-plus中又查询...

fendo 6921

从零到一:基于STM32F103C8T6与HAL库的磁悬浮电赛装置实战解析

本文详细解析了基于STM32F103C8T6微控制器与HAL库,从零构建磁悬浮装置的完整实战方案。文章深入剖析了硬件设计中的线圈布局与“反向串联”巧思,以节省PWM资源;并阐述了采用三闭环PID控制算法的软件实现,结合Keil开发环境与HAL库进行工程搭建与调试。该方案为电子设计竞赛(电赛)提供了高可行性的参考,是嵌入式软硬件综合实践的优秀范例。

weixin_29169505的博客 273

ESP8266-Arduino网络编程实例-异步TCP客户端

本次实例将使用ESPAsyncTCP库实现一个简单的客户端。

视觉与物联智能 1740

Mybatis-Plus与spring boot整合时数据库连接失败

在运行启动文件时,报错,显示数据库链接失败(错误信息忘记粘贴) 问题描述:spring boot 配置文件application.yml中连接数据库的配置文件路径一直写的是localhost,但是改为本机的ip之后启动项目报错,连接不上数据库 问题原因:mysql 没有开启远程允许远程连接的权限 解决办法:开启mysql 的远程连接权限 具体步骤: 1 用命令登录或者Navicat 登录到数据库,我的用户名和密码分别为 root 123456 2 登录之后切换到mysql 数据库,然后输入下..

果酱的博客 1727

微信服务号配置总是提示“参数错误”?我就是这样一步步查出问题的

前两天,我遇到了一个很诡异的问题:在微信服务号后台配置服务器地址时,总是提示“参数错误,请重新填写”。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 1277

springboot 整合 mybatisplus 连接数据库

本案例在 IDEA 中建一个 springboot 项目 结合 mybatisplus 来连接数据,并打印数据表中的信息;并介绍 springboot 中的三层架构是一个MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。无侵入损耗小强大的 CRUD 操作支持 Lambda 形式调用支持主键自动生成支持 ActiveRecord 模式支持自定义全局通用操作内置代码生成器内置分页插件分页插件支持多种数据库内置性能分析插件内置全局拦截插件详细见官方文档。

2401_83017604的博客 3010

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

SpringBoot整合MyBatis和MyBatis Plus、Junit的注意事项

所以在整合任意技术的时候,如果你想直观感触到简化的效果,你必须先知道使用非SpringBoot技术时对应的整合是如何做的,然后再看基于SpringBoot的整合是如何做的,才能比对出来简化在了哪里。这里设置的UTC是全球标准时间,你也可以理解为是英国时间,中国处在东八区,需要在这个基础上加上8小时,这样才能和中国地区的时间对应的,也可以修改配置不写UTC,写Asia/Shanghai也可以解决这个问题。一个注解就搞定了,而且还没有参数,再体会SpringBoot整合其他技术的优势在哪里,就两个字——

weixin_69912448的博客 881

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Spring Boot 和 MyBatis-Plus 的简单整合

打开浏览器访问http://localhost:8080/UserController/insert,可以看到页面上打印“数据插入成功”,刚好和UserController类中的代码功能一致,同时控制台也打印出了insert语句,说明调用成功。MyBatis是一个强大且稳定的持久层解决方案,也是众多java程序员入门的首选,而MyBatis-Plus是MyBatis 的增强工具,在MyBatis的基础上只做增强不做改变,为简化开发、提高效率而生。需要配置好自己的数据库连接,用户名,密码。

D_J_Dragon的博客 4326

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

十八,Spring Boot 整合 MyBatis-Plus 的详细配置

MyBatis-Plus 官网文档:https://baomidou.com/是一个MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。MyBatis puls (简称 MP) 是一个Mybatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发,提供效率而生。内置通用Mapper,通用 Service,通过少量配置即可实现单表大部分的CRUD操作,更有强大的条件构造器,满足各类使用需求。

m0_74824123的博客 1145

spring boot整合mybatis-plus提示org.apache.ibatis.binding.BindingException: Invalid bound statement

错误提示信息:mybatis绑定异常,无效的绑定报告;这个错误主要是因为一些文件名或者配置名称写错导致的错误。 下面是整合流程 在pom文件中引入依赖(注意version的版本要选择正确,有些版本存在问题) <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>

六六的小帅的博客 1715

Spring Boot整合MyBatis-plus

步骤一:在项目的pom.xml文件当中引入MyBatis-plus依赖 <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.1</version> &lt.

hpf_coding的博客 335
上一篇: SQL Server中类似MySQL的REPLACE INTO语句
下一篇: Spring Boot整合MyBatis配置多数据源
程序员null
博客等级 码龄11年 1304粉丝 124原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值