紧接上文
导入了log4j和slf4j-lo4j的jar包之后,又提示如下异常
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/hibernate/News.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:671)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1679)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
at com.hibernate.NewsManager.main(NewsManager.java:10)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:604)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:668)
... 7 more
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1621)
at co
通过这句异常日志Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".分析,是由于映射文件头和跟节点不匹配,映射文件的头文件应该如下:
<!DOCTYPE hibernate-mapping PUBLIC
          "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

顺便提一下,Hibernate配置文件的头文件如下:
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

Exception in thread quot;mainquot; org.hibernate.InvalidMappingException: Could not pars相关推荐

  1. 成功解决:Exception in thread quot;AWT-EventQueue-0quot;

    成功解决:Exception in thread "AWT-EventQueue-0" 目录 解决问题 解决思路 解决问题 Exception in thread "AW ...

  2. 【已解决】关于IDEA中 Driver 出现Exception in thread quot;mainquot; java.lang.NullPointerException问题

    在学习hive过程中,按照mapreduce编程规范,分别编写Mapper,Reducer,Driver,在编写Driver后运行报错了,花了两天,找到了解决方案(裂开.JPG). 代码: packa ...

  3. Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could n

    今天在写ssh的时候遇到了一个这样的问题,连登陆页面都进不去了 报错信息如下: 严重: Exception sending context initialized event to listener ...

  4. Exception in thread main org.hibernate.TransientObjectException: object references an unsaved tran

    今天在使用一对多,多对一保存数据的时候出现了这个错误 Hibernate错误: Exception in thread "main" org.hibernate.Transient ...

  5. Exception in thread main java.lang.NoClassDefFoundError: antlr/ANTLRException 解决方法

    struts2.3.15 hibernate 3.2.0 整合,报错Exception in thread "main" java.lang.NoClassDefFoundErro ...

  6. Exception in thread main java.lang.Error: 无法解析的编译问题: 方法 main 不能声明为 static;只能在静态类型或顶级类型中才能声明静态方法

    Exception in thread "main" java.lang.Error: 无法解析的编译问题: 方法 main 不能声明为 static:只能在静态类型或顶级类型中才 ...

  7. exception in thread main java.lang.noclassdeffounderror wrong name

    不含包层次的HelloWorld.java public class HelloWorld{ public static void main(String[] args) { System.out.p ...

  8. Exception in thread main java.lang.Error: Unresolved compilation problem

    初学java,使用eclipse编译时,可能会遇到如下图所示的编译错误(Exception in thread "main" java.lang.Error: Unresolved ...

  9. Exception in thread http-bio-80exec-1 java.lang.OutOfMemoryError: PermGen s解决方案

    问题描述: Exception in thread ""http-bio-80"-exec-1" java.lang.OutOfMemoryError: Per ...

最新文章

  1. 输入法按照选字频率排序的C语言程序算法,算法与数据结构之选择排序(C语言)...
  2. 机器学习 | 数据从哪里找?手把手教你构建数据集
  3. linux和unix文件没有创建时间,Linux中没有文件创建时间的概念
  4. 从 Zero 到 Hero ,一文掌握 Python--转
  5. java项目教训_[免费电子书]分析超过600,000个Java项目的经验教训
  6. JavaFX技巧来节省内存! 属性和可观察物的阴影场
  7. C++ ACM模式输入输出
  8. ASP.NET 2.0 – 善用DataSourceMode属性 (转自章立民CnBlogs)
  9. C++复习 auto
  10. RSA的JavaScript程序
  11. 02C++namespace命名空间
  12. Android入门(四)UI-创建自定义控件
  13. Atitit.播放系统规划新版本 v4 q18 and 最近版本回顾
  14. 计算机操作系统答案(完整版)
  15. 数据结构c语言描述 试题,数据结构c语言版试题大全(含答案)
  16. Python微信公众号接入图灵机器人
  17. Python关键字keyword
  18. adb push php,ADB指令合集-ADB指令如何执行刷Recovery,重启进Recovery,双Wipe和刷ROM手机刷机...
  19. unity shader projector使用
  20. Quantile-Quantile (q-q) Plots

热门文章

  1. oracle一直在更新注册表,WIN7安装卡死在更新注册表设置真正解决办法
  2. 机器学习中的矩阵分解方法
  3. Docker 核心技术与实现原理,这篇写得比较清楚
  4. 深圳市企业信息化建设补贴项目申报材料
  5. python中def之间变量传递_Python def函数的定义、使用及参数传递实现代码
  6. PDF转JPG图片使用ICEPDF,解决水印的问题
  7. HashMap面试底层原理(原作者很厉害)
  8. 2021/11/2第5讲
  9. 每个游戏公司的领导都应该看看Supercell的“十年总结”
  10. 一种模仿学习方法来训练机器人,而无需进行实际的人类演示