項目啟動時報錯Element type "property" must be followed by either attribute specifications, ">" or "/>"
項目啟動時,控制台報錯,信息如下(有刪減):
Error creating bean with name 'supplierInfoDAO' defined in class path resource [conf/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [conf/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
... 79 more
Caused by: org.dom4j.DocumentException: Error on line 138 of document : Element type "property" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "property" must be followed by either attribute specifications, ">" or "/>".
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:532)
... 83 more
錯誤信息指向的文檔信息如下:
138行是正確的配置,怎麼看都沒有問題, 想當然的認為,不可能是空格的問題,結果出人意料,就 是因為屬性之間缺少了一個空格,導致SAX解析XML文件時報錯導致,將文件修改為如下即可
項目運行正常了。
查看本欄目