其他分享
首页 > 其他分享> > org.springframework.beans.factory.UnsatisfiedDependencyException

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>

标签:factory,springframework,bean,beans,org,UnsatisfiedDependencyException
来源: https://blog.csdn.net/kawsaki/article/details/123184296