1,创建项目时导入mybatis依赖,
2,pom.xml文件会自动导入mybatis依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
3,在application.yml文件下写配置文件
mybatis:
mapper-locations: classpath:mapping/*Mapper.xml
type-aliases-package: com.zzuli.entity
或者配置文件是application.properties
4, 注意,配置类不能放在java目录下,需要创建包放在controller包同级目录下。否则报错
Your ApplicationContext is unlikely to start due to a
@ComponentScan of the default package.