Mybatis介绍

本文介绍了Mybatis作为持久层框架的作用,并详细讲解了如何在Springboot中集成Mybatis,包括数据源设置、依赖导入、注解使用,如@Mapper和@Options。此外,文章还讨论了分页查询,推荐使用PageHelper插件,并提到了Lombok插件及其常用注解,如@Data和@Slf4j。最后,作者介绍了Mybatis XML配置文件的规则及常用标签。
摘要由CSDN通过智能技术生成


前言

Mybatis是持久层框架,用来简化JDBC开发的

Springboot集成mybatis框架

数据源设置

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/cai
spring.datasource.username=root
spring.datasource.password=1234
#控制台输出mybatis日志
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl  
#开启驼峰命名 如果字段名与属性名符合驼峰命名规则,mybatis会自动通过驼峰命名规则映射
mybatis.configuration.map-underscore-to-camel-case=true
#通过包扫描的方式为包起别名 然后就可以直接指定类名就可以了,不需要在xml指定全类名
mybatis.type-aliases-package=com.example.domain

需要导入的依赖

  这里需要导入的mybatis
   <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值