1. 程式人生 > >啟動項目報錯:org.springframework.beans.factory.UnsatisfiedDependencyException

啟動項目報錯:org.springframework.beans.factory.UnsatisfiedDependencyException

ini ali 監聽 exp date ram factor 接口 xml文件

dubbo項目:

啟動項目報錯:(web端)

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userController‘: Unsatisfied dependency expressed through field ‘userService‘; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.refile.api.service.UserService‘ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

原因:

一直以為是dubbo端服務沒有正常提供接口服務,但發現報錯的內容和找不到dubbo接口服務異常內容不一樣,所以懷疑不是dubbo提供接口服務問題。

找了半天發現是web端啟動的時候沒有掃描到dubbo消費端的配置文件。

解決辦法:

修改web.xml文件的內容:

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/refile-mvc.xml</param-value>
</context-param>

改為classpath:spring/*.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/*.xml</param-value>
</context-param>

spring監聽器:

<context-param>
        <param-name>contextConfigLocation</
param-name> <param-value>classpath:spring/refile-mvc.xml</param-value> </context-param>

啟動項目報錯:org.springframework.beans.factory.UnsatisfiedDependencyException