MybatisPlus的使用步骤

小灰灰 2023-09-29 19:20 142阅读 0赞

MybatisPlus使用步骤

1.导入MybatisPlus坐标

  1. <!-- MybatisPlus坐标-->
  2. <dependency>
  3. <groupId>com.baomidou</groupId>
  4. <artifactId>mybatis-plus-boot-starter</artifactId>
  5. <version>3.0.5</version>
  6. </dependency>

2.在配置文件中配置mapper映射路径

  1. # 应用名称
  2. spring.application.name=springboot_test03
  3. # 应用服务 WEB 访问端口
  4. server.port=18082
  5. #下面这些内容是为了让MyBatis映射
  6. #指定Mybatis的Mapper文件
  7. #mybatis.mapper-locations=classpath:mappers/*xml
  8. mybatis-plus.mapper-locations=classpath:mappers/*xml
  9. #指定Mybatis的实体目录
  10. mybatis.type-aliases-package=com.xyh.mybatis.entity
  11. # 数据库驱动:
  12. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  13. # 数据源名称
  14. spring.datasource.name=defaultDataSource
  15. # 数据库连接地址
  16. spring.datasource.url=jdbc:mysql://localhost:3306/springboot?serverTimezone=UTC
  17. # 数据库用户名&密码:
  18. spring.datasource.username=root
  19. spring.datasource.password=xyh123
  20. #pagehelper分页插件配置
  21. pagehelper.helper-dialect=mysql
  22. pagehelper.reasonable=true
  23. pagehelper.support-methods-arguments=true
  24. pagehelper.params=count=countSql
  25. logging.level.com.xyh:debug

3.在dao层去继承BaseMapper

  1. @Mapper
  2. public interface QuotationDao extends BaseMapper<QuotationQueryPageFansVo> {
  3. // 分页查询
  4. List<QuotationQueryPageFansVo> queryPage(QuotationQueryPageVo quotationQueryPageVo);
  5. }

4.内部提供了很多简单的sql语句,复杂的还是需要我们手动写

发表评论

表情:
评论列表 (有 0 条评论,142人围观)

还没有评论,来说两句吧...

相关阅读