目录
BaseMapper查询语句用法:
Wrapper:
Wrapper子句构造器父类:
用@Data和加依赖代替实体类中的toString Getter和Setter方法
验证 List selectList(@Param("ew") Wrapper queryWrapper);语句:
Page类:
在启动类中添加下面的方法,即可告诉MyBatis,我们使用的是MySql数据库:
框架整合:
创建工程:
创建web目录:
安装依赖 MySQL版本降级:
配置web/resource目录 JSP的前缀和后缀 Tomcat端口号:
开启MyBatis的SQL语句日志打印:
创建文件:
BaseMapper查询语句用法:
Wrapper:
双击Shift找Wrapper的源代码:
Wrapper子句构造器父类:
1.QueryWrapper
2.UpdateWrapper
用@Data和加依赖代替实体类中的toString Getter和Setter方法
org.projectlombok lombok
@Data注解:用于注解实体类
验证 List selectList(@Param("ew") Wrapper queryWrapper);语句:
Page类:
在启动类中添加下面的方法,即可告诉MyBatis,我们使用的是MySql数据库:
验证> E selectPage(E page, @Param("ew") Wrapper queryWrapper);方法:
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}
框架整合:
创建工程:
创建web目录:
安装依赖 MySQL版本降级:
org.apache.tomcat.embed
tomcat-embed-jasper
provided
jstl
jstl
1.2
provided
taglibs
standard
1.1.2
provided
配置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
src/main/web
META-INF/resources
***.xml
**/*.properties
开启MyBatis的SQL语句日志打印:
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}
创建文件:
Page类:
在启动类中添加下面的方法,即可告诉MyBatis,我们使用的是MySql数据库:
验证
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}
框架整合:
创建工程:
创建web目录:
安装依赖 MySQL版本降级:
org.apache.tomcat.embed tomcat-embed-jasperprovided jstl jstl1.2 provided taglibs standard1.1.2 provided
配置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
src/main/web META-INF/resources ***.xml **/*.properties
开启MyBatis的SQL语句日志打印:
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}
创建文件:



