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

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