上一篇:IDEA+springboot+thymeleaf+mysql的简单登录
本文基于IDEA+springboot+thymeleaf+mysql的简单登录完成上进行的。
上篇的查询为手写的查询登录,这里我们可以使用maven自导的mybatis的单表mapper通用使用
步骤
1.在maven官网查询mapper的maven引入包到pom.xml
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
2.添加mapper的配置到application.properties中
#mapper
#mappers 多个接口时逗号隔开
mapper.mappers=com.mls.sopp.util.mapper.MyMapper
mapper.not-empty=false
mapper.identity=mysql
mapper.order=BEFORE
3.整理通用mapper的工具类
BaseService.java
package com.example.demo.common;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @说明
* @作者: hehe
* @时间: 2018-03-21
*/
public class BaseService<T> implements IService<T> {
@Autowired
protected Mapper<T