目标:配置Mybatis在Spring Boot工程中的整合包,设置Mybatis实体类别名,输出执行SQL语句配置项
分析:
1、添加依赖器
2、配置Mybatis实体类别名称、日志、映射文件等
3、配置MapperaScan
小结:
1、添加Mybatis官方对于springboot的依赖器
<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、设置启动类中的mapper扫描