Springboot整合mybaits报mapper注入失败@org.springframework.beans.factory.annotation.Autowired(required=true)
报错信息如下:
Field studentMapper in com.ccut.ebusiness.module.school.service.StudentService required a bean of type ‘com.ccut.ebusiness.module.school.mapper.StudentMapper’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
解决办法:
首先检查代码有没有问题,看mapper有没有@Mapper 和@Repository这两个注解,
再看pom文件里面导入mybaits依赖没有
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>