当前位置:网站首页>8.03 Day34---BaseMapper查询语句用法
8.03 Day34---BaseMapper查询语句用法
2022-08-04 05:24:00 【您算哪块小饼干?】
目录
用@Data和加依赖代替实体类中的toString Getter和Setter方法
验证 List selectList(@Param("ew") Wrapper queryWrapper);语句:
在启动类中添加下面的方法,即可告诉MyBatis,我们使用的是MySql数据库:
配置web/resource目录 JSP的前缀和后缀 Tomcat端口号:
BaseMapper查询语句用法:
Wrapper:

双击Shift找Wrapper的源代码:

Wrapper子句构造器父类:
1.QueryWrapper<T> 作为where条件子句的构造器
2.UpdateWrapper<T> 修改set子句的构造器
用@Data和加依赖代替实体类中的toString Getter和Setter方法

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>@Data注解:用于注解实体类




验证 List<T> selectList(@Param("ew") Wrapper<T> queryWrapper);语句:


Page类:
在启动类中添加下面的方法,即可告诉MyBatis,我们使用的是MySql数据库:
验证<E extends IPage<T>> E selectPage(E page, @Param("ew") Wrapper<T> queryWrapper);方法:

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}






框架整合:

创建工程:


创建web目录:


安装依赖 MySQL版本降级:

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<scope>provided</scope>
</dependency>
配置web/resource目录 JSP的前缀和后缀 Tomcat端口号:

spring.application.name=springboot-mybatisplus-01 server.port=8084 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.name=defaultDataSource spring.datasource.url=jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.username=root spring.datasource.password=root mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl spring.mvc.view.prefix=/jsp/ spring.mvc.view.suffix=.jsp

<resources>
<resource>
<directory>src/main/web</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>开启MyBatis的SQL语句日志打印:

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}创建文件:











边栏推荐
- 入坑软件测试的经验与建议
- Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
- 某母婴小程序加密参数解密
- flink cdc一启动,源端Oracle那台服务器的CPU就飙升到80%以上,会是啥原因呢?
- 腾讯136道高级岗面试题:多线程+算法+Redis+JVM
- 深度学习21天——卷积神经网络(CNN):实现mnist手写数字识别(第1天)
- 少年成就黑客,需要这些技能
- word 公式编辑器 键入技巧 | 写数学作业必备速查表
- 《看见新力量》第四期免费下载!走进十五位科技创业者的精彩故事
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
猜你喜欢
随机推荐
自动化测试的成本高效果差,那么自动化测试的意义在哪呢?
DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
OpenSSF 安全计划:SBOM 将驱动软件供应链安全
C语言 -- 操作符详解
力扣:343. 整数拆分
使用Patroni回调脚本绑定VIP的坑
The difference between px, em, and rem
编程大杂烩(三)
JS基础--强制类型转换(易错点,自用)
word 公式编辑器 键入技巧 | 写数学作业必备速查表
基于gRPC编写golang简单C2远控
Will the 2023 PMP exam use the new version of the textbook?Reply is here!
腾讯136道高级岗面试题:多线程+算法+Redis+JVM
有趣的 Kotlin 0x0E:DeepRecursiveFunction
Towards Real-Time Multi-Object Tracking (JDE)
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
如何打造一篇优秀的简历
路网编辑器技术预研
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.5 数组和指针的其他区别
【评价类模型】Topsis法(优劣解距离法)









