A component required a bean of type '**.IStudentServer' that could not be found

933 阅读1分钟

在启动项目的时候,控制台抛出 “A component required a bean of type '** .IStudentServer' that could not be found”错误。

image.png

仔细看这句话的意思大概是无法找到IStudentServer这个类型的bean,因为是使用springboot开发,第一时间就能联想到是注解问题,进入到IStudentServer接口,可以看到并没有使用任何注解。

image.png

进入接口实现类,发现就是少了@service注解,不能创建对象并放到spring容器中,导致没有该对象的bean。添加@Service注解后,就能正常启动了。

image.png