org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'teacherController': Unsatisfied dependency expressed through field 'teacherService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'teacherServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'wg.study.springboot.mapper.TeacherMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
原因:
在spring boot整合mybatisplus时出现此类报错,一般是因为启动类中的包扫描注解没加,项目找不到所需要的mapper文件
解决办法:
启动类上方加上包扫描注解@MapperSacan,加上mapper文件位置
或者在mapper.xml文件中加上@Mapper注解