weixin_35947773 2016-08-24 09:47 采纳率: 0%
浏览 7852

添加多个<context:component-scan base-package/>总是报错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appArticleInfoController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.icekredit.nanjing.service.impl.AppArticleInfoServiceImpl com.icekredit.nanjing.controller.AppArticleInfoController.appArticleInfoService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appArticleInfoServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.icekredit.util.CommonUtil com.icekredit.nanjing.service.impl.AppArticleInfoServiceImpl.commonUtil; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.icekredit.util.CommonUtil] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我的spring-mvc.xml

<context:component-scan base-package="com.***.***.controller"/>
<context:component-scan base-package="com.***.***.service.impl"/>
<context:component-scan base-package="com.***.***.service"/>
<context:component-scan base-package="com.***.***.mapper"/>
<context:component-scan base-package="com.***.***.controller"/>
<context:component-scan base-package="com.***.***.service.impl"/>
<context:component-scan base-package="com.***.***.service"/>
<context:component-scan base-package="com.***.***.mapper"/>

![图片说明](https://img-ask.csdn.net/upload/201608/24/1472031980_843879.jpg)
  • 写回答

2条回答 默认 最新

  • 小与哥 2016-08-25 03:21
    关注

    它已经提示你了, 看这里 NoSuchBeanDefinitionException:
    No qualifying bean of type [com.icekredit.util.CommonUtil] found for dependency

    没有这样的 bean 异常, base-package 再添加个范围:

     <context:component-scan base-package= "com.*.*.CommonUtil"/>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?