Error creating bean with name 'com.mp.mybatis.MybatisApplicationTests': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mp.service.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}报错原因分析:
1、Service层没有添加@Service注解
2、有@Service仍然报错
解决办法:在SpringBoot的启动类@SpringBootApplication上添加scanbasePackages = {“com.mp.service”},扫描Service层
@SpringBootApplication(scanbasePackages = {"com.mp.service"})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)