MybatisPlus使用步骤
1.导入MybatisPlus坐标
<!-- MybatisPlus坐标-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
2.在配置文件中配置mapper映射路径
# 应用名称
spring.application.name=springboot_test03
# 应用服务 WEB 访问端口
server.port=18082
#下面这些内容是为了让MyBatis映射
#指定Mybatis的Mapper文件
#mybatis.mapper-locations=classpath:mappers/*xml
mybatis-plus.mapper-locations=classpath:mappers/*xml
#指定Mybatis的实体目录
mybatis.type-aliases-package=com.xyh.mybatis.entity
# 数据库驱动:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# 数据源名称
spring.datasource.name=defaultDataSource
# 数据库连接地址
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?serverTimezone=UTC
# 数据库用户名&密码:
spring.datasource.username=root
spring.datasource.password=xyh123
#pagehelper分页插件配置
pagehelper.helper-dialect=mysql
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true
pagehelper.params=count=countSql
logging.level.com.xyh:debug
3.在dao层去继承BaseMapper
@Mapper
public interface QuotationDao extends BaseMapper<QuotationQueryPageFansVo> {
// 分页查询
List<QuotationQueryPageFansVo> queryPage(QuotationQueryPageVo quotationQueryPageVo);
}
4.内部提供了很多简单的sql语句,复杂的还是需要我们手动写