关于SpringBoot启动报错Consider defining a bean of type ‘xx.xx.*Service‘ in your configuration.

编程知识 更新时间:2023-05-02 05:31:47

关于SpringBoot启动报错Consider defining a bean of type 'xx.xx.*Service' in your configuration

  • 1、问题详情
  • 2、问题解读
  • 3、解决方法

1、问题详情

***************************
APPLICATION FAILED TO START
***************************
Description:
Field appFileService in com.cloud.appfile.fileserver.UploadFileController required a bean of type 'com.cloud.service.appfile.AppFileService' 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 'com.cloud.service.appfile.AppFileService' in your configuration.

2、问题解读

提示原意:考虑定义一个类型为’com.cloud.service网站.appfile.AppFiles服务’在你的配置中。

也就是说你交给Spring管理的某个Service bean没有扫描到,导致无法进行实例化。

解决思路是:指定扫描包路径进行加载

3、解决方法

在SpringBoot的启动类中加入@ComponentScan,格式如下所示的代码:

@ComponentScan(basePackages = {"指定的包路径"})

实例演示如下:

更多推荐

关于SpringBoot启动报错Consider defining a bean of type ‘xx.xx.*Service‘ in your config

本文发布于:2023-04-26 06:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/0d89f2d32c5e3f678a6b7bb37639bc24.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   bean   defining   SpringBoot   Service

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104590文章数
  • 26216阅读数
  • 0评论数