1. 程式人生 > >Error creating bean with name 'fileController': Injection of resource dependencies failed;

Error creating bean with name 'fileController': Injection of resource dependencies failed;

alt context http original pen isp listener uestc file

1.錯誤描述

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name fileController: Injection of resource dependencies failed; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case
, use RequestContextListener or RequestContextFilter to expose the current request.

2.問題解決

【1】網上很多的方法都是在web.xml裏面增加監聽器;但是原本已經有了,所以不是監聽器的問題。

【2】後來發現代碼中多了一行@Resource註解;刪除即可解決問題。

技術分享圖片

Error creating bean with name 'fileController': Injection of resource dependencies failed;