XML:The processing instruction must begin with the name of the target

在剛剛學習Hibernate時運行出現了下邊的錯誤:

Exception in thread "main" org.hibernate.MappingException: Could not read mappings from resource: com/j2ee/hibernate/User.hbm.xml
    at org.hibernate.cfg.Configuration.addClass(Configuration.java:506)
    at com.j2ee.hibernate.UserClient.<init>(UserClient.java:10)
    at com.j2ee.hibernate.UserClient.main(UserClient.java:55)
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:431)
    at org.hibernate.cfg.Configuration.addClass(Configuration.java:503)
    ... 2 more
Caused by: org.dom4j.DocumentException: Error on line 1 of document  : The processing instruction must begin with the name of the target. Nested exception: The processing instruction must begin with the name of the target.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
    ... 3 more

發現是**.hbm.xml文件的錯誤如圖:

**.hbm.xml錯誤

點擊錯誤提醒,錯誤提示爲:

The processing instruction must begin with the name of the target

解決方法:將?與xml之間的空格消除,就能順利運行了。

希望能幫到各位小夥伴......

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章