MyBatis-Plus使用小结
2024-10-09 00:00:07
官网:
https://mybatis.plus/
https://gitee.com/baomidou/mybatis-plus
https://github.com/baomidou/mybatis-plus
1.引入依赖:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1.tmp</version>
</dependency>
2.编写自己接口继承BaseMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@Repository
public interface StuDescMapper extends BaseMapper<StuDesc> {}
3.设置yml文件,官方配置介绍https://mybatis.plus/config/
spring:
datasource:
name: student_info
url: jdbc:mysql://127.0.0.1:3306/student_info?serverTimezone=GMT%2B8
username: root
password: test
driver-class-name: com.mysql.cj.jdbc.Driver
server:
port: 9090
#根据自己的需求配置
mybatis-plus:
mapperLocations: classpath:mapper/*.xml
configuration :
mapUnderscoreToCamelCase: true
globalConfig:
banner: true
4.编辑实体,官方注解说明https://mybatis.plus/guide/annotation.html
@TableName(value = "s_desc")
public class StuDesc {
private String id;
@TableId
private Integer userId;
private String scoreLevel;
@TableField(value = "`desc`")
private String desc;
5.crdu的使用
查询条件的构造:
QueryWrapper<StuDesc> stuDescQueryWrapper = new QueryWrapper<>();
(1)QueryWrapper可以直接填充实体StuDesc,根据实体的内容去执行;
(2)QueryWrapper也可构造添加去执行,stuDescQueryWrapper.eq(“表字段名”,“具体的值”);
附加:MyBatis-Plus功能很强大,还有很多功能可以使用,
CRUD 接口:https://mybatis.plus/guide/crud-interface.html
条件构造器:https://mybatis.plus/guide/wrapper.html
最新文章
- 【分布式协调】之理解paxos
- iOS开发UIScrollView的底层实现
- HP-Socket
- Raspberry Pi3 ~ 搭建开发环境
- ZOJ 2015 10月份 月赛 3911 Prime Query
- homebrew for mac
- 基于Spring Boot的图片上传
- K:Union-Find(并查集)算法
- A tuple is defined as a function
- Lodop打印语句最基本结构介绍(什么是一个任务)
- VS2017+WIN10自动生成类、接口的说明(修改类模板的方法)
- error C4996: &#39;GetVersionExW&#39;: 被声明为已否决
- 1finally与return、exit()
- 【Jenkins学习 】解决jenkins运行磁盘满的问题
- [javaSE] GUI(对话框Dialog)
- 【移动端debug-1】css3中box-shadow的溢出问题
- xeno 实时性能测试 在100us的采样周期的测试数据
- Oracle11gr2_ADG管理之switchover补充
- git push &; git pull 推送/拉取分支
- python 循环内部添加多个条件判断会出现越界
热门文章
- ORM单表查询,跨表查询,分组查询
- Oracle连接别人数据库
- POJ1523 Tarjan求割点以及删除割点之后强连通分量的数量
- CF1326A Bad Ugly Numbers 题解
- React Hook上车
- 动态规划-不连续最大子序列和-打家劫舍系列-1388. 3n 块披萨
- C 2012年笔试题(保)
- leetcode并发题解
- 用一个例子说说gRPC的四种服务方法
- 值传递:pass by value(按值传递) 和 pass by reference(引用传递)-[all]-[编程原理]