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之间的空格消除,就能顺利运行了。

希望能帮到各位小伙伴......

猜你喜欢

转载自blog.csdn.net/Xiao_Bai_Ke/article/details/83410928