在用@Autowire注解的时候如果会显红,首先检查代码。一般是没有注入依赖,比如我的显红是因为没有给ProductServiceImpl添加@Service

但是如果代码可以正常运行

idea遇到Could not autowire. No beans of 'ProductServiceImpl' type found. less... (Ctrl+F1) Inspection

解决方法:

点击File--Settings

idea遇到Could not autowire. No beans of 'ProductServiceImpl' type found. less... (Ctrl+F1) Inspection

最后显红没有了

idea遇到Could not autowire. No beans of 'ProductServiceImpl' type found. less... (Ctrl+F1) Inspection

相关文章: