栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

关于SpringBoot无法找到Service层的说明,报错:A component required a bean of type ‘*‘ that could not be found

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

关于SpringBoot无法找到Service层的说明,报错:A component required a bean of type ‘*‘ that could not be found

关于SpringBoot无法找到Service层的说明

SpringBoot的报错信息为:
Description:
A component required a bean of type ‘*****.service’ that could not be found.

Action:
Consider defining a bean of type ‘*****.service’ in your configuration.

Process finished with exit code 1

出现这个问题的根本原因就是spring没找到你的Service注解

1、你的service层没有写在springboot启动类的同级或者下级目录
像这样:
这样spring是扫描不到service文件的

2、你的@Service注解写在了接口上
这种情况下,这个@Service注解也是不会生效的,也会产生上述的错误

我们只能将@Service注解写在Service的实现类impl那个类上,才能使注解正常生效

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/888825.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号