解决IDEA的Could not autowire. No beans of ‘***‘ type found.

提示:其实这是一个和spring的底层逻辑(控制反转与依赖注入)有关的问题


前言

在跟写springboot项目时发现的问题:如下图,大概率是由于该类未加上spring注解,故没有被注入到spring中,一个很常见的新手小白会遇到的问题。


一、Spring常用注解

  1. @Repository /@Mapper:数据访问层(dao层)
  2. @Service :业务逻辑层(service层)
  3. @Controller :控制层(controller层)

注(后端框架):

 

二、解决方法

在类上加上对应的spring注解

返回查看问题已解决( ͡• ͜ʖ ͡• )


三、其他可参考解决方案

如果想要暂时的去掉这个问题的error报错,不想因为这个问题影响代码的运行

方案一:可以在IDEA设置里将该问题改成warning后,该问题被只会警告提示,不会影响运行

 方案二:给 @Autowired加上一个(required = false),表示我暂时不需要处理这个问题,报错也会消失

  • 10
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"Could not autowire. No beans of 'JieConfigurationService' type found." 这个错误提示通常出现在Spring框架中,表示在注入依赖时找不到对应的bean。这可能是由于以下几个原因导致的: 1. 没有在Spring容器中声明或配置 'JieConfigurationService' bean。请确保在配置文件或使用注解的方式中正确配置了该bean。 2. 'JieConfigurationService' bean 配置的名字与注入注解中引用的名字不一致。请检查注入的代码,确保注解中的名字与bean的名字一致。 3. 依赖包或类文件缺失。检查是否缺少了引用 'JieConfigurationService' 类的依赖包或者类文件。确保该类在编译时可以被正确找到。 综上所述,要解决这个问题,你需要检查以下几个方面:确认 'JieConfigurationService' bean 已经在Spring容器中正确配置,并且注解中引用的名字与配置的名字一致。同时,确保依赖包和类文件都存在并被正确引入。这样,你应该能够解决 "Could not autowire. No beans of 'JieConfigurationService' type found." 的错误提示。 #### 引用[.reference_title] - *1* *2* [Could not autowire. No beans of ‘XXX‘ type found](https://blog.csdn.net/weixin_44096133/article/details/128679145)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [Idea 解决 Could not autowire. No beans of 'xxxx' type found 的错误提示](https://download.csdn.net/download/weixin_38632624/12751965)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值