关于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那个类上,才能使注解正常生效