SSM 整合发生异常:Error creating bean with name 'itemsController': Injection of resource dependencies fail

心已赠人 2024-02-18 15:07 25阅读 0赞

运行SSM工程发生异常:

  1. Error creating bean with name 'itemsController':
  2. Injection of resource dependencies failed;
  3. nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
  4. No qualifying bean of type [com.hlx.service.ItemsService] found for dependency:
  5. expected at least 1 bean which qualifies as autowire candidate for this dependency.
  6. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

原因:web.xml文件在加载配置文件时,没有写classpath:

解决:

  1. <!--1) 加载spring容器 -->
  2. <context-param>
  3. <param-name>contextConfigLocation</param-name>
  4. <param-value>classpath:applicationContext-*.xml</param-value>
  5. </context-param>

发表评论

表情:
评论列表 (有 0 条评论,25人围观)

还没有评论,来说两句吧...

相关阅读