当前位置:网站首页>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; }
创建文件:
边栏推荐
猜你喜欢
【云原生--Kubernetes】Pod资源管理与探针检测
What is the salary of a software testing student?
震惊,99.9% 的同学没有真正理解字符串的不可变性
入坑软件测试的经验与建议
Programming hodgepodge (4)
关于yolo7和gpu
谷粒商城-基础篇(项目简介&项目搭建)
少年成就黑客,需要这些技能
[One step in place] Jenkins installation, deployment, startup (complete tutorial)
Get the selected content of the radio box
随机推荐
[21 Days Learning Challenge] Image rotation problem (two-dimensional array)
sql server如何得到本条记录与上一条记录的差异,即变动值
企业需要知道的5个 IAM 最佳实践
There is an 8 hour difference between the docker installation of mysql and the host.
Redis common interview questions
The symbol table
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.4 Matching declarations to definitions
leetcode 12. 整数转罗马数字
C Expert Programming Chapter 5 Thinking about Linking 5.1 Libraries, Linking and Loading
商城系统APP如何开发 都有哪些步骤
21 days learning challenge 】 【 sequential search
处理List<Map<String, String>>类型
idea设置识别.sql文件类型以及其他文件类型
Introduction and application of go module
C专家编程 第5章 对链接的思考 5.4 警惕Interpositioning
OpenGL绘制一个圆锥
DataTable uses Linq for grouping and summarization, and converts the Linq result set into DataTable
在被面试官说了无数次后,终于潜下心来整理了一下JVM的类加载器
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
leetcode 12. Integer to Roman numeral