No qualifying bean of type ‘com.atguigu.springboot.bean.Person’ available: expected at least 1 bean which qualifies as autowire candidate.

问题复现:在Person person;上面添加@Autowired后,出现红色波浪线
Could not autowire. No beans of ‘Person‘ type found
运行测试类后报的错误如下:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.atguigu.springboot.bean.Person’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

出错原因:没有在person类上面添加@Component,它的作用是:把普通Java对象实例化到spring容器中。(

Could not autowire. No beans of ‘Person‘ type found

相关文章:

  • 2021-07-13
  • 2021-07-29
  • 2021-04-13
  • 2021-10-15
  • 2021-10-27
  • 2022-12-23
猜你喜欢
  • 2021-11-22
  • 2021-06-29
  • 2021-08-11
  • 2021-04-25
  • 2021-08-27
  • 2021-06-04
相关资源
相似解决方案