今天覆習一下Spring和Hibernate的整合,遇到了一個問題,報錯信息如下:
org.springframework.beans.factory.xml。XmlBeanDefinitionStoreException:來自類路徑資源的XML文檔中的第1行是無效的;嵌套異常
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允許有內容。
根據其意思是XML的文件出現了問題,網上說的問題是 更改xml文件的編碼、xml文件第一行有空格 等,折騰了幾次,最後發現是沒有指定解析哪個xml文件。(如圖)
1. 錯誤:未指定xml文件路徑
2. 正確
總結:這個問題折騰了不少時間,算是爲自己的馬虎大意付出了代價。