目录
1.MyBatis概述
MyBatis是一款优秀的持久层(DAO)框架,用于简化JDBC的开发,和数据库打交道。它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作
比如说如果想要查询所有用户的数据,普通SQL语句是select * from users;而MyBatis就是通过java语句操作数据库查询
2.MyBatis简单入门
Day08-14. Mybatis-入门-快速入门程序_哔哩哔哩_bilibili
下面是SpringBoot的MyBatis项目创建后pom.xml配置文件中的常见依赖:
<!-- springboot父工程 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- mybatis起步依赖 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<!-- mysql驱动包,一般默认是最新版本 -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!-- springboot单元测试依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
在Spring Boot项目中,pojo文件夹通常用来存放“Plain Old Java Objects”,也就是简单的Java对象,比如简单的User类对象