全部
技术
PHP
MySQL
前端
Linux
JAVA
工具
纪念日计算器
邮记星
个人记账
笔记侠
历史上的今天
生日密码
生日书
生日密码
生日花语
博古通今
三十六计
鬼谷子
笑林广记
本草纲目
山海经
唐诗宋词
宋词300首
唐诗300首
退出
登录
注册
编辑文章
选择分类
PHP
MySQL
前端
Linux
Java
工具
选择专栏
设计模式
java基础
Angular学习
Java面试题
描述:
封面图上传 :
+
点击上传图片
在使用SpringBoot自动注解,如下,idea提示找不到CatalogService这个bean ``` @Autowired CatalogService catalogService; ``` 报错信息如下: ``` 019-03-12 16:49:37.191 ERROR 8492 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field catalogService in top.bowen.controller.IndexController required a bean of type 'top.bowen.service.CatalogService' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'top.bowen.service.CatalogService' in your configuration. Process finished with exit code 0 ``` 大概意思就是找不到top.bowen.service下面的CatalogService,想啦很久我路径下面也有这个文件,为啥找不到呢。 原来,我们在使用top.bowen.service下面的CatalogService时,缺少了注解**@Service**,**@Service注解**帮助我们声明CatalogService时是一个bean,这点很重要,因为CatalogService是一个bean,其他的类才可以使用@Autowired将CatalogService作为一个成员变量自动注入,不然就会找不到
保存文章