**Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:== No qualifying bean of type ==‘com.shop1.service.userinfoService’ available: expected at ==least 1 bean which qualifies as autowire candidate. 的解决方法 **
错误发现地点
##在userinfoServiceImplTest中定义一个userinfoServiceImpl类型的变量,变量名字为uiService,发现变量下有红色波浪线
且导致后面的queryById 运行出错
错误信息
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:== No qualifying bean of type ==‘com.shop1.service.userinfoService’ available: expected at ==least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
解决方法
1
回到userinfoServiceImpl,会发现
==public class userinfoServiceImpl…{}==没有加注释
2
给userinfoServiceImpl加上注释@Service
3
这时再回去测试userinfoServiceImplTest的queryById就会运行成功