当前位置:网站首页>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;
}创建文件:











边栏推荐
- C Expert Programming Chapter 5 Thinking about Linking 5.3 5 Special Secrets of Library Linking
- [Evaluation model] Topsis method (pros and cons distance method)
- day13--postman interface test
- Bolb analysis of image processing (1)
- 路网编辑器技术预研
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
- JS基础--强制类型转换(易错点,自用)
- 高性能高可靠性高扩展性分布式防火墙架构
- DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
- day13--postman接口测试
猜你喜欢
随机推荐
[Cocos 3.5.2]开启模型合批
12、分页插件
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
2022年PMP考试延迟了,该喜该忧?
About yolo7 and gpu
4.2 声明式事务概念
使用Patroni回调脚本绑定VIP的坑
商城系统APP如何开发 都有哪些步骤
QT 如何识别文件的编码格式
BFC、IFC、GFC、FFC概念理解、布局规则、形成方法、用处浅析
Write golang simple C2 remote control based on gRPC
Dynamic programming of the division of numbers
CentOS7 —— yum安装mysql
[Evaluation model] Topsis method (pros and cons distance method)
string类简介
The difference between px, em, and rem
Bolb analysis of image processing (1)
el-Select selector bottom fixed
C专家编程 第5章 对链接的思考 5.2 动态链接的优点
代码重构:面向单元测试









