在Springboot整合mybaties的过程中,楼主出现了扫码不到mapper包的问题,错误原因如下:
错误原因:
Description:
Parameter 0 of constructor in edu.seig.mybatiesspringboot.controller.ProblemController required a bean of type 'edu.seig.mybatiesspringboot.mapper.ProblemMapper' that could not be found.
Action:
Consider defining a bean of type 'edu.seig.mybatiesspringboot.mapper.ProblemMapper' in your configuration.
楼主的项目结构如下:

可以看出启动类的放置位置并无问题,因此默认配置应该能扫到,但是依旧出现错误。
最后找到错误原因是依赖版本过低的问题。
原先楼主的依赖:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
升级成:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
之后运行,成功解决。
Spring Boot整合MyBatis扫不到mapper包问题解决
893

被折叠的 条评论
为什么被折叠?



