解决异常:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name

报错信息:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘receiverController’: Unsatisfied dependency expressed through field ‘service’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.teemlink.sync.service.SyncService’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)

在这里插入图片描述
从报错信息可以知道,在注入receiverController这个bean时发生错误,而发生这种错误的原因有以下几种:
1、检查receiverController这个类有没有添加@Controller注解

2、检查receiverController类调用的service类有没有添加@Service注解

3、检查receiverController类下的Dao层或Mapper层类上有没有添加注解

4、检查启动类上包扫描有没有扫描到receiverController类
解决异常:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name_第1张图片
我这次的情况是启动类上没有添加receiverController类的包扫描,而以前报这个错误是因为忘记添加注解,所以报了该异常

欢迎大家阅读,本人见识有限,写的博客难免有错误或者疏忽的地方,还望各位大佬指点,在此表示感谢。觉得本文章有帮助到的,点个赞呗

你可能感兴趣的:(路过的一些坑BUG,Spring,boot,spring,boot,java,bug,spring)