org.springframework.beans.factory.UnsatisfiedDependencyException

错误信息
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name ‘indexController’: Unsatisfied dependency expressed through field ‘bookService’; nested exception is org.springframework.beans.factory.
UnsatisfiedDependencyException: Error creating bean with name ‘bookService’:
Unsatisfied dependency expressed through field ‘bookMapper’; nested exception is org.springframework.beans.factory.
NoSuchBeanDefinitionException: No qualifying bean of type ‘com.project.dao.BookMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我已经是二次入坑了,第一次没有做记录,结果导致第二次又忘了

解决办法
有以下几个原因:

1)service接口实现类上有没有加@Service注解,注解是不是引用的spring的类?不要导错包

2)接口有没有写实现类,实现类是实现的对应接口么?

3)有没有扫描Service所在的包

4)确保代码无误后,再看看包是否下载完整

  1. 查看注入是否正确

6)是否正确配置Listenter(就是这个原因一直在卡我)

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
上一篇:UBUNTU PYTHON 3.7 开发机 BASELINE


下一篇:JavaScript的安全性问题(js不能做什么)--来自新浪勇敢的心的博客