天天看點

java.io.FileNotFoundException: class path resource [XXX] cannot be opened because

這兩天在學習SSM整合,遇到了一個很讓人意外的問題:

HTTP Status 500 – Internal Server Error

Type 異常報告

消息 Servlet.init() for servlet [DispatcherServlet] threw exception

描述 伺服器遇到一個意外的情況,阻止它完成請求。

Exception

javax.servlet.ServletException: Servlet.init() for servlet [DispatcherServlet] threw exception

Root Cause

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

解決方法:

删除xml配置檔案中的注釋即可

可能你很意外,注釋不是很正常的一個操作嘛?我也意外,前後問了很多人,有的人不能有注釋,但有的人可以,這個不知道是idea的Bug,還是什麼原因,我使用的是idea2019.3.2,以後如果知道具體原因了,再來更正。