1.添加启动器依赖
<!--mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
2.配置Mybatis
在配置文件中配置如下
mybatis:
# 实体类别名包路径
type-aliases-package: com.itheima.pojo
# 映射文件路径
# mapper-locations: classpath:mappers/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
3.配置MapperScan
添加@MapperScan标签扫描

本文介绍了如何在Spring Boot项目中添加Mybatis启动器依赖,配置Mybatis类型别名包和映射文件,以及使用@MapperScan进行Mapper接口扫描。重点讲解了配置细节和实践步骤。
582

被折叠的 条评论
为什么被折叠?



