SpringBoot使用注解@Mapper和@MapperScan注解无效

今天小伙伴问了一个问题,挺有意思的 分享给大家
在SpringBoot整合MyBatis的时候,service层,dao层注解都已经添加了,
还是出现Could not find bean with name “XXXMapper”

是因为少一个jar包的缘故,导致@Mapper 和 @MapperScan都未能生效

 <!--缺少此jar包,导致@Mapper@MapperScan注解无效-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>

添加此依赖,注解就可正常使用!


版权声明:本文为DuanXianSen原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。