当前位置:网站首页>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; }
创建文件:
边栏推荐
- 离线采集怎么看sql执行计划
- Hangdian Multi-School-Slipper- (tree map conversion + virtual point mapping)
- Do you think border-radius is just rounded corners?【Various angles】
- C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.5 Other Differences Between Arrays and Pointers
- npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
- 嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
- Uni-app 小程序 App 的广告变现之路:全屏视频广告
- day13--postman接口测试
- Plus版SBOM:流水线物料清单PBOM
- Resolved error: npm WARN config global `--global`, `--local` are deprecated
猜你喜欢
Towards Real-Time Multi-Object Tracking(JDE)
字节最爱问的智力题,你会几道?
[21 Days Learning Challenge] Image rotation problem (two-dimensional array)
There is an 8 hour difference between the docker installation of mysql and the host.
CentOS7 —— yum安装mysql
信息学奥赛一本通 1312:【例3.4】昆虫繁殖
Get the selected content of the radio box
Towards Real-Time Multi-Object Tracking (JDE)
符号表
自动化测试的成本高效果差,那么自动化测试的意义在哪呢?
随机推荐
DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片
有趣的 Kotlin 0x0E:DeepRecursiveFunction
[SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
How to simplify the automation of modern e-procurement?
解决错误:npm WARN config global `--global`, `--local` are deprecated
深度学习环境配置
Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
离线采集怎么看sql执行计划
入坑软件测试的经验与建议
JS基础--强制类型转换(易错点,自用)
day13--postman接口测试
MySql数据恢复方法个人总结
Introduction and application of go module
附加:对于“与数据表对应的实体类“,【面对MongoDB时,使用的@Id等注解】和【以前面对MySQL时,使用的@Id等注解】,是不同的;
The Road to Ad Monetization for Uni-app Mini Program Apps: Full Screen Video Ads
el-Select 选择器 底部固定
redis中常见的面试题
leetcode 12. Integer to Roman numeral
企业需要知道的5个 IAM 最佳实践
商城系统APP如何开发 都有哪些步骤