Java的UnsatisfiedDependencyException和NoSuchBeanDefinitionException异常信息

  • Post author:
  • Post category:java


具体报错如下:

在这里插入图片描述

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

这里指的就是无法从容器中找到 bookDao 这个 bean 就无法自动注入

在这里插入图片描述

最后通过在启动类上添加@MapperScan扫到你自己需要用的包下就完美解决

在这里插入图片描述

我是有点不理解这个还需要自己设置,看教学视频的时候都不需要。这报错信息解决方式很多都不一样,需要自己一个一个找然后试 -_-‘’



版权声明:本文为PeppaPigwww原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。