No qualifying bean of type ==‘com.shop1.service.userinfoService’ available解决方法

时间:2024-04-06 16:06:47

**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 运行出错
No qualifying bean of type ==‘com.shop1.service.userinfoService’ available解决方法

错误信息

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)}

No qualifying bean of type ==‘com.shop1.service.userinfoService’ available解决方法

解决方法

1
回到userinfoServiceImpl,会发现
==public class userinfoServiceImpl…{}==没有加注释
No qualifying bean of type ==‘com.shop1.service.userinfoService’ available解决方法
2
给userinfoServiceImpl加上注释@Service
No qualifying bean of type ==‘com.shop1.service.userinfoService’ available解决方法
3
这时再回去测试userinfoServiceImplTest的queryById就会运行成功
No qualifying bean of type ==‘com.shop1.service.userinfoService’ available解决方法