当前位置:网站首页>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; }
创建文件:
边栏推荐
- C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
- px、em、rem的区别
- 编程大杂烩(四)
- MySQL数据库面试题总结(2022最新版)
- C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.5 数组和指针的其他区别
- 力扣:509. 斐波那契数
- 【SemiDrive源码分析】【MailBox核间通信】47 - 分析RPMSG_IPCC_RPC 方式 单次传输的极限大小 及 极限带宽测试
- leetcode 12. Integer to Roman numeral
- Towards Real-Time Multi-Object Tracking(JDE)
猜你喜欢
随机推荐
C Expert Programming Chapter 5 Thinking about Linking 5.2 Advantages of Dynamic Linking
21 days learning challenge 】 【 sequential search
力扣:70. 爬楼梯
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
MySQL日志篇,MySQL日志之binlog日志,binlog日志详解
Use Patroni callback script to bind VIP pit
8大软件供应链攻击事件概述
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
【21 Days Learning Challenge】Direct Insertion Sort
el-Select 选择器 底部固定
Will the 2023 PMP exam use the new version of the textbook?Reply is here!
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
商城App开发都有哪些功能呢
解决错误:npm WARN config global `--global`, `--local` are deprecated
嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
MySQL数据库面试题总结(2022最新版)
The idea setting recognizes the .sql file type and other file types
[Evaluation model] Topsis method (pros and cons distance method)
详解八大排序
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work