当前位置:网站首页>8.03 Day34---BaseMapper query statement usage
8.03 Day34---BaseMapper query statement usage
2022-08-04 05:30:00 【Which cookie are you?】
目录
BaseMapperquery statement usage:
WrapperClause constructor parent class:
用@Dataand add dependencies instead of the ones in the entity classtoString Getter和Setter方法
验证 List selectList(@Param("ew") Wrapper queryWrapper);语句:
Add the following method in the startup class,即可告诉MyBatis,我们使用的是MySql数据库:
配置web/resource目录 JSP的前缀和后缀 Tomcat端口号:
开启MyBatis的SQLStatement log print:
BaseMapperquery statement usage:
Wrapper:
双击Shift找Wrapper的源代码:
WrapperClause constructor parent class:
1.QueryWrapper<T> 作为whereConstructor for conditional clauses
2.UpdateWrapper<T> 修改setConstructor for clauses
用@Dataand add dependencies instead of the ones in the entity classtoString Getter和Setter方法
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency>
@Data注解:用于注解实体类
验证 List<T> selectList(@Param("ew") Wrapper<T> queryWrapper);语句:
Page类:
Add the following method in the startup class,即可告诉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的SQLStatement log print:
@Bean public MybatisPlusInterceptor mybatisPlusInterceptor(){ MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL); mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor); return mybatisPlusInterceptor; }
创建文件:
边栏推荐
猜你喜欢
Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用
[C language advanced] program environment and preprocessing
部署LVS-DR群集【实验】
Shocked, 99.9% of the students didn't really understand the immutability of strings
编程大杂烩(四)
解决错误:npm WARN config global `--global`, `--local` are deprecated
触觉智能分享-SSD20X实现升级显示进度条
Resolved error: npm WARN config global `--global`, `--local` are deprecated
【一步到位】Jenkins的安装、部署、启动(完整教程)
What is the salary of a software testing student?
随机推荐
SLSA 框架与软件供应链安全防护
[C language advanced] program environment and preprocessing
C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
5个开源组件管理小技巧
Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
触觉智能分享-SSD20X实现升级显示进度条
力扣:70. 爬楼梯
动态规划总括
Cannot read properties of null (reading ‘insertBefore‘)
The Road to Ad Monetization for Uni-app Mini Program Apps: Full Screen Video Ads
C专家编程 第5章 对链接的思考 5.1 函数库、链接和载入
数的划分之动态规划
px、em、rem的区别
详解八大排序
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
redis中常见的面试题
C Expert Programming Chapter 5 Thinking about Linking 5.2 Advantages of Dynamic Linking