目录
MybatisPlus官网
一、MybatisPlus介绍
MyBatis-Plus 是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。
1.1. 支持的数据库如下

1.2. 框架结构

1.3. 特性
无侵入:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑
损耗小:启动即会自动注入基本 CURD,性能基本无损耗,直接面向对象操作
强大的 CRUD 操作:内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求
支持 Lambda 形式调用:通过 Lambda 表达式,方便的编写各类查询条件,无需再担心字段写错
支持主键自动生成:支持多达 4 种主键策略(内含分布式唯一 ID 生成器 - Sequence),可自由配置,完美解决主键问题
支持 ActiveRecord 模式:支持 ActiveRecord 形式调用,实体类只需继承 Model 类即可进行强大的 CRUD 操作
支持自定义全局通用操作:支持全局通用方法注入( Write once, use anywhere )
内置代码生成器:采用代码或者 Maven 插件可快速生成 Mapper 、 Model 、 Service 、 Controller 层代码,支持模板引擎,更有超多自定义配置等您来使用
内置分页插件:基于 MyBatis 物理分页,开发者无需关心具体操作,配置好插件之后,写分页等同于普通 List 查询
分页插件支持多种数据库:支持 MySQL、MariaDB、Oracle、DB2、H2、HSQL、SQLite、Postgre、SQLServer 等多种数据库
内置性能分析插件:可输出 SQL 语句以及其执行时间,建议开发测试时启用该功能,能快速揪出慢查询
内置全局拦截插件:提供全表 delete 、 update 操作智能分析阻断,也可自定义拦截规则,预防误操作
1.4. 注意点
全新的 MyBatis-Plus 3.0 版本基于 JDK8,提供了 lambda 形式的调用,所以安装集成 MP3.0 要求如下:JDK 8+ 以及Maven or Gradle
版本 3.5.8+ 最低要求 JDK 11+
MyBatisPlus官方提供了starter,其中集成了Mybatis和MybatisPlus的所有功能,并且实现了自动装配效果。 因此我们可以用MybatisPlus的starter代替Mybatis的starter
二、MybatisPlus基本使用步骤
通过MybatisPlus实现下列功能:
新增用户功能
根据id查询用户
根据id批量查询用户
根据id更新用户
根据id删除用户
2.1. 引入依赖
引入MybatisPlus依赖,代替Mybatis依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.7</version>
</dependency>
2.2. 定义Mapper接口
自定义的Mapper继承MybatisPlus提供的BaseMapper接口:
package com.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.User;
public interface UserMapper extends BaseMapper<User> {
}
2.3. 业务实体类
package com.example.domain;
import lombok.Data;
@Data
public class User {
private int id;
private String username;
private int age;
}
2.4. BaseMapper源码

2.5. 测试代码
package com.example.mybatisplusdemo2;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void insert() {
User user = new User();
user.setAge(1);
user.setUsername("王哲晓");
userMapper.insert(user);
}
@Test
void update() {
User user = new User();
user.setAge(1);
user.setUsername("王哲晓");
userMapper.insert(user);
}
}
2.6. 启动类
package com.example;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@MapperScan("com.example.mapper")
@SpringBootApplication
public class MybatisplusDemo2Application {
public static void main(String[] args) {
SpringApplication.run(MybatisplusDemo2Application.class, args);
}
}
MyBatisPlus通过扫描实体类,并基于反射获取实体类信息作为数据库表信息。
三、MybatisPlus常见注解
MybatisPlus中比较常用的几个注解如下:
@TableName:用来指定表名
@TableId:用来指定表中的主键字段信息
@TableField:用来指定表中的普通字段信息

IdType枚举:
AUTO:数据库自增长
INPUT:通过set方法自行输入
ASSIGN_ID:分配 ID,接口IdentifierGenerator的方法nextId来生成id默认实现类为DefaultIdentifierGenerator雪花算法
使用@TableField的常见场景:
成员变量名与数据库字段名不一致
成员变量名以is开头,且是布尔值
成员变量名与数据库关键字冲突
成员变量不是数据库字段
四、MybatisPlus常见配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/mybatisplus-demo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: root
password: Wangzhexiao1991@
mybatis-plus:
type-aliases-package: com.itheima.mp.domain.po # 别名扫描包
mapper-locations: "classpath*:/mapper/**/*.xml" # Mapper.xml文件地址,默认值
configuration:
map-underscore-to-camel-case: true # 是否开启下划线和驼峰的映射
cache-enabled: false # 是否开启二级缓存
global-config:
db-config:
id-type: assign_id # id为雪花算法生成
update-strategy: not_null # 更新策略:只更新非空字段
五、条件构造器
5.1. 源码结构图
MyBatisPlus支持各种复杂的where条件,可以满足日常开发的所有需求。条件构造器的源码实现类结构图如下:



5.2. 基于QueryWapper查询
查询姓王的,年龄大于26岁的人的id、姓名和年龄。
package com.example.mybatisplusdemo2;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void select() {
// 1.构建查询条件
QueryWrapper<User> wrapper = new QueryWrapper<User>()
.select("id", "username", "age")
.like("username", "王")
.ge("age", 26);
// 2.查询
List<User> users = userMapper.selectList(wrapper);
users.forEach(System.out::println);
}
}
5.3. 基于QueryWapper更新
更新姓名叫王哲晓的年龄为2000岁
package com.example.mybatisplusdemo2;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void update() {
// 1.要更新的数据
User user = new User();
user.setAge(2000);
// 2.更新的条件
QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("username", "王哲晓");
userMapper.update(user, wrapper);
}
}
5.4. 基于UpdateWrapper更新
更新id为1,2,4的用户的年龄,减10岁。
package com.example.mybatisplusdemo2;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void update() {
List<Long> ids = List.of(1L , 2L, 4L);
// 2.更新的条件
UpdateWrapper<User> wrapper = new UpdateWrapper<User>()
.setSql("age = age - 10")
.in("id", ids);
userMapper.update(wrapper);
}
}
5.5. 基于LambdaQueryWapper查询
查询姓王且年龄大于20的人
package com.example.mybatisplusdemo2;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void update() {
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<User>()
.select(User::getId, User::getUsername, User::getAge)
.like(User::getUsername, "王")
.ge(User::getAge, 20);
List<User> users = userMapper.selectList(wrapper);
users.forEach(System.out::println);
}
}
六、自定义SQL
将id在指定范围的用户(例如1,2,4)的金额改为指定值
传统实现方式:
package com.example.mybatisplusdemo2;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void update() {
List<Long> ids = List.of(1L,2L,4L);
userMapper.updateAgeByIds(ids);
}
}
package com.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.User;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface UserMapper extends BaseMapper<User> {
void updateAgeByIds(@Param("ids") List<Long> ids);
}
<?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.mapper.UserMapper">
<update id="updateAgeByIds">
UPDATE user
SET age = age - 5
WHERE id IN
<foreach collection="ids" separator="," item="id" open="(" close=")">
#{id}
</foreach>
</update>
</mapper>
自定义SQL实现方式:
我们可以利用MyBatisPlus的Wrapper来构建复杂的Where条件,然后自己定义SQL语句中剩下的部分。
基于Wrapper构建where条件
package com.example.mybatisplusdemo2;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private UserMapper userMapper;
@Test
void update() {
List<Long> ids = List.of(1L,2L,4L);
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<User>().in(User::getId, ids);
userMapper.updateAgeByIds(wrapper, 5);
}
}
在mapper方法参数中用Param注解声明wrapper变量名称,必须是ew
package com.example.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.User;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface UserMapper extends BaseMapper<User> {
void updateAgeByIds(@Param("ew") LambdaQueryWrapper<User> wrapper, @Param("num") int num);
}
自定义SQL,并使用Wrapper条件
<?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.mapper.UserMapper">
<update id="updateAgeByIds">
UPDATE User SET age = age - #{num} ${ew.customSqlSegment}
</update>
</mapper>
七、Service接口
7.1. Service结构图


7.2. Service实现代码
自定义Service接口继承IService接口
package com.example.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.domain.User;
public interface IUserService extends IService<User> {
}
自定义Service实现类,实现自定义接口并继承ServiceImpl类
package com.example.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import com.example.service.IUserService;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
}
使用Service接口进行增删改查:
package com.example.mybatisplusdemo2;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.domain.User;
import com.example.mapper.UserMapper;
import com.example.service.IUserService;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class MybatisplusDemo2ApplicationTests {
@Resource
private IUserService userService;
@Test
void update() {
List<Long> ids = List.of(1L,2L,4L);
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper();
wrapper.ge(User::getAge, 20);
List<User> users = userService.list(wrapper);
users.forEach(System.out::println);
}
}
7.3. IService的Lambda查询
传统编写方式:

IService的Lambda查询替代写法 :
@GetMapping("/list")
public List<UserVO> queryUsers(UserQuery query){
// 1.查询用户PO
List<User> users = userService.queryUsers(
query.getName(), query.getStatus(), query.getMinBalance(), query.getMaxBalance());
// 2.把PO拷贝到VO
return BeanUtil.copyToList(users, UserVO.class);
}
@Override
public List<User> queryUsers(String name, Integer status, Integer minBalance, Integer maxBalance) {
return lambdaQuery()
.like(name != null, User::getUsername, name)
.eq(status != null, User::getStatus, status)
.ge(minBalance != null, User::getBalance, minBalance)
.le(maxBalance != null, User::getBalance, maxBalance)
.list();
}
List<User> queryUsers(String name, Integer status, Integer minBalance, Integer maxBalance);
7.4. IService的Lambda更新
@Override
@Transactional
public void deductBalance(Long id, Integer money) {
// 1.查询用户
User user = getById(id);
// 2.校验用户状态
if (user == null || user.getStatus() == UserStatus.FROZEN) {
throw new RuntimeException("用户状态异常!");
}
// 3.校验余额是否充足
if (user.getBalance() < money) {
throw new RuntimeException("用户余额不足!");
}
// 4.扣减余额 update tb_user set balance = balance - ?
int remainBalance = user.getBalance() - money;
lambdaUpdate()
.set(User::getBalance, remainBalance)
.set(remainBalance == 0, User::getStatus, UserStatus.FROZEN)
.eq(User::getId, id)
.eq(User::getBalance, user.getBalance()) // 乐观锁
.update();
}
7.5. IService的批量新增
批量插入10万条用户数据,并作出对比:
普通for循环插入
速度极差(不推荐)
@Test
void testSaveOneByOne() {
long b = System.currentTimeMillis();
for (int i = 1; i <= 100000; i++) {
userService.save(buildUser(i));
}
long e = System.currentTimeMillis();
System.out.println("耗时:" + (e - b));
}
private User buildUser(int i) {
User user = new User();
user.setUsername("user_" + i);
user.setPassword("123");
user.setPhone("" + (18688190000L + i));
user.setBalance(2000);
user.setInfo(UserInfo.of(24, "英文老师", "female"));
user.setCreateTime(LocalDateTime.now());
user.setUpdateTime(user.getCreateTime());
return user;
}
默认情况下MP的IService的批量插入
基于预编译的批处理(性能不错),但是多条数据一次性提交还是执行多条插入的SQL,性能没有达到最好。
@Test
void testSaveBatch() {
// 我们每次批量插入1000条件,插入100次即10万条数据
// 1.准备一个容量为1000的集合
List<User> list = new ArrayList<>(1000);
long b = System.currentTimeMillis();
for (int i = 1; i <= 100000; i++) {
// 2.添加一个user
list.add(buildUser(i));
// 3.每1000条批量插入一次
if (i % 1000 == 0) {
userService.saveBatch(list);
// 4.清空集合,准备下一批数据
list.clear();
}
}
long e = System.currentTimeMillis();
System.out.println("耗时:" + (e - b));
}
开启rewriteBatchedStatements=true参数
配置该JDBC参数,开启rewriteBatchedStatements(性能最好),多条数据一次性提交且合并执行一条插入的SQL。

八、基于Restful风格实现下列接口

8.1. Controller控制层类
package com.example.controller;
import cn.hutool.core.bean.BeanUtil;
import com.example.domain.dto.UserFormDTO;
import com.example.domain.po.User;
import com.example.domain.vo.UserVO;
import com.example.service.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "用户管理接口")
@RequestMapping("/users")
@RestController
@RequiredArgsConstructor
public class UserController {
private final IUserService userService;
@Operation(summary = "新增用户接口")
@PostMapping
public void saveUser(@RequestBody UserFormDTO userFormDTO) {
// 1.把DTO拷贝到PO
User user = BeanUtil.copyProperties(userFormDTO, User.class);
// 2.新增
userService.save(user);
}
@Operation(summary = "删除用户接口")
@Parameter(name = "id", description = "用户id", in = ParameterIn.PATH)
@DeleteMapping
public void deleteUserById(@PathVariable("id") Long id) {
userService.removeById(id);
}
@Operation(summary = "根据ID查询用户接口")
@Parameter(name = "id", description = "用户id", in = ParameterIn.PATH)
@GetMapping("id")
public UserVO queryUserById(@PathVariable("id") Long id) {
// 1. 查询用户PO
User user = userService.getById(id);
// 2.把PO拷贝到VO
return BeanUtil.copyProperties(user, UserVO.class);
}
@Operation(summary = "根据ID批量查询用户接口")
@Parameter(name = "ids", description = "用户id集合", in = ParameterIn.QUERY)
@GetMapping
public List<UserVO> queryUserByIds(@RequestParam("ids") List<Long> ids) {
// 1. 查询用户PO
List<User> users = userService.listByIds(ids);
// 2.把PO拷贝到VO
return BeanUtil.copyToList(users, UserVO.class);
}
@Operation(summary = "扣减用户余额接口")
@Parameters({@Parameter(name = "id", description = "用户id", in = ParameterIn.PATH),
@Parameter(name = "money", description = "扣减金额", in = ParameterIn.PATH)
})
@PutMapping("/{id}/deduction/{money}")
public void deductBalance(@PathVariable("id") Long id, @PathVariable("money") Integer money) {
userService.deductBalance(id, money);
}
}
8.2. Servcie接口
package com.example.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.domain.po.User;
public interface IUserService extends IService<User> {
void deductBalance(Long id, Integer money);
}
8.3. Service实现类
package com.example.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.domain.po.User;
import com.example.enums.UserStatus;
import com.example.mapper.UserMapper;
import com.example.service.IUserService;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
@Override
public void deductBalance(Long id, Integer money) {
// 1.查询用户
User user = getById(id);
// 2.校验用户状态
if (user == null || user.getStatus() == UserStatus.FROZEN) {
throw new RuntimeException("用户状态异常!");
}
// 3.校验余额是否充足
if (user.getBalance() < money) {
throw new RuntimeException("用户余额不足!");
}
// 4.扣减余额
baseMapper.deductBalance(id, money);
}
}
8.4. Mapper
package com.example.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.po.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface UserMapper extends BaseMapper<User> {
void updateAgeByIds(@Param("ew") LambdaQueryWrapper<User> wrapper, @Param("num") int num);
@Update("UPDATE User SET balance = balance - #{money} WHERE id = #{id}")
void deductBalance(@Param("id") Long id, @Param("money") Integer money);
}
8.5. 实体枚举类
package com.example.domain.dto;
import lombok.Data;
@Data
public class UserFormDTO {
private Long id;
private String username;
private String password;
private String phone;
private String userInfo;
private Integer balance;
}
package com.example.domain.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.example.enums.UserStatus;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@TableName(autoResultMap = true)
public class User {
private Long id;
private String username;
private String password;
private String phone;
private Integer age;
private Integer balance;
private UserStatus status;
@TableField(typeHandler = JacksonTypeHandler.class)
private UserInfo userInfo;
}
package com.example.domain.po;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserInfo {
private Integer age;
private String intro;
private String gender;
}
package com.example.domain.vo;
import lombok.Data;
@Data
public class UserVO {
private Long id;
private String username;
private Integer balance;
}
package com.example.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
@Getter
public enum UserStatus {
NORMAL(1, "正常"),
FROZEN(2, "冻结");
@EnumValue
private final int value;
@JsonValue
private final String desc;
UserStatus(int value, String desc) {
this.value = value;
this.desc = desc;
}
}
8.6. application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/mybatisplus-demo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: root
password: Wangzhexiao1991@
mybatis-plus:
type-aliases-package: com.itheima.mp.domain.po # 别名扫描包
# mapper-locations: classpath*:/mapper/**/*.xml # Mapper.xml文件地址,默认值
configuration:
map-underscore-to-camel-case: true # 是否开启下划线和驼峰的映射
cache-enabled: false # 是否开启二级缓存
default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
global-config:
db-config:
id-type: assign_id # id为雪花算法生成
update-strategy: not_null # 更新策略:只更新非空字段
knife4j:
enable: true
openapi:
title: 用户管理接口文档
description: "用户管理接口文档"
email: 11122533@qq.com
concat: 王哲晓
url: https://www.wangzhexiao.cn
version: v1.0.0
group:
default:
group-name: default
api-rule: package
api-rule-resources:
- com.example.controller
8.7. UserMapper.xml
<?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>3.3.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>mybatisplus-demo2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mybatisplus-demo2</name>
<description>mybatisplus-demo2</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.7</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.32</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.11</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-web</artifactId>
<version>3.0.0</version>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>




被折叠的 条评论
为什么被折叠?



