使用@Autowired报错Could not autowire. No beans of 'xxx' type found

原文  https://blog.csdn.net/weixin_42209881/article/details/95312071

 

我遇到的错误原因分为两种情况:
第一种:
注入的时候,导入的对象类路径不对,检查一下导入的路径

import com.zhang.demo.service.IKPIDailyReportService;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

 

有时候有重名的类,就导致错误了,我就遇到过类似错误。
第二种:
也是经常遇到的,就是@Autowired的自动检测级别太高,可以使用下边的方法,或者把Error级改为提示或者警告
在这里插入图片描述

posted @ 2021-01-19 14:53  监听员  阅读(188)  评论(0编辑  收藏  举报