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>

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

你可能感兴趣的:(spring,boot,mybatis,java)