- 引入坐标
<!--====================MyBatis=====================-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
在 Mapper 接口上使用注解 @Mapper
application.yml 配置文件中配置 mapper.xml 的位置
#Mybatis配置
mybatis:
#mapper映射文件的位置
mapper-locations: classpath:mapper/*.xml
- 整合过程中有出现无法扫描到 mapper.xml 的问题
主要原因:没有在 application.yml 文件中配置 mapper.xml 的位置
- 在搜索问题时,有人说在启动类上加注解:@MapperScan(basePackages = “com.leolau.mapper”) 可以解决
个人测试:无法解决扫描不到映射问题。
- 以上仅代表我个人测试,有疑问可以留言~