转自:http://www.itzhai.com/invalidmappingexception-could-not-parse-mapping-document-prompt-the-wrong-solution.html

org.hibernate.InvalidMappingException: Could not parse mapping document from resource …(错误的xml文件)

出现这样的错误一般是映射文件中映射出错了,找到错误提示resource 后面提示的xml文件,对应POJO对象逐个检查,看是否遗漏了某些属性的配置,或者写错了。

举个例子:
package com.exam.entity;
import java.util.Set;
public class SubjectChapter {
private int chapterId;
private String chapterName;
private Subject subject;
private int chapterNum;
private Set question;
public int getChapterId() {
return chapterId;
}
public void setChapterId(int chapterId) {
this.chapterId = chapterId;
}
public String getChapterName() {
return chapterName;
}
public void setChapterName(String chapterName) {
this.chapterName = chapterName;
}
public Subject getSubject() {
return subject;
}
public void setSubject(Subject subject) {
this.subject = subject;
}
public int getChapterNum() {
return chapterNum;
}
public void setChapterNum(int chapterNum) {
this.chapterNum = chapterNum;
}
public Set getQuestion() {
return question;
}
public void setQuestion(Set question) {
this.question = question;
}
}
<hibernate-mapping package="com.exam.entity">
<class name="SubjectChapter" table="exam_subject_chapter">
<id name="chapterId" column="chapter_id">
<generator class="increment" />
</id>
<property name="chapterName" column="chapter_name"/>
<many-to-one name="subject" column="subject_id" cascade="all"/>
<property name="chapterNum" column="chapter_num"/>
<set name="question" inverse="true">
<key column="subject_chapter_id"/>
<one-to-many class="Question"/>
</set> </class>
</hibernate-mapping>

这里原本少写了chapterNum的映射,导致该错误的出现。

InvalidMappingException提示Could not parse mapping document错误的解决方法的更多相关文章

  1. Win7/Win8 系统下安装Oracle 10g 提示“程序异常终止,发生未知错误”的解决方法

    我的Oracle 10g版本是10.2.0.1.0,(10.1同理)选择高级安装,提示“程序异常终止,发生未知错误”. 1.修改Oracle 10G\database\stage\prereq\db\ ...

  2. nginx提示:500 Internal Server Error错误的解决方法

    现在越来越多的站点开始用 Nginx ,("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 ...

  3. 【转】nginx提示:500 Internal Server Error错误的解决方法

    本文转自:http://www.jb51.net/article/35675.htm 现在越来越多的站点开始用 Nginx ,("engine x") 是一个高性能的 HTTP 和 ...

  4. linux下mysql提示"mysql deamon failed to start"错误的解决方法

    操作系统为centos,网站突然连接不上数据库,于是朋友直接重启了一下服务器.进到cli模式下,执行 service myqsld start 发现还是提示"mysql deamon fai ...

  5. MySQL之——提示"mysql deamon failed to start"错误的解决方法

    网站突然连接不上数据库,于是直接重启了一下服务器.进到cli模式下,执行 service myqsld start 发现还是提示"mysql deamon failed to start&q ...

  6. Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)

    今天配置Spring的xml出现了错误 Multiple annotations found at this line: - schema_reference.4: Failed to read sc ...

  7. mkdir()提示No such file or directory错误的解决方法

    转自:http://www.02405.com/program/php/1692.html 在php中使用mkdir()方法创建文件夹时报错:No such file or directory,出错代 ...

  8. yii webservice 提示:Procedure 'getSent' not present 错误的解决方法(转)

    其实根据常用的webservice清除缓存方法,在client端加入这样一句话: ini_set("soap.wsdl_cache_enabled", "0") ...

  9. org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/book.hbm.xml 联网跑一跑

    org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/domain/boo ...

随机推荐

  1. 百度小程序 配置 app.json 文件

    可以通过配置 app.json 文件,设置 SWAN 的界面.路径.多 TAB 等. app.json 配置项列表如下 属性 类型 必填 描述 pages Array.<string> 是 ...

  2. [USACO08FEB]连线游戏Game of Lines

    题目背景 Farmer John最近发明了一个游戏,来考验自命不凡的贝茜. 题目描述 Farmer John has challenged Bessie to the following game: ...

  3. php命令行工具

    https://jingyan.baidu.com/article/37bce2beb6e5681002f3a20f.html

  4. jsoncpp 能做什么

    jsoncpp能做什么1)跨平台跨语言动态信息数据交换.2)作为格式化配置文件使用3)对应数据结构数据类型做序列化和反序列化4)value::toStyledString 格式化json串输出 一.w ...

  5. [CF1082G]Petya and Graph:最小割

    分析 发这篇博客的目的就是要让你们知道博主到底有多菜. 类似于[NOI2006]最大获利.(明明就是一模一样好吧!) 不知道怎么了,半秒就想到用网络流,却没想出怎么建图. 连这么简单的题都没做出来,我 ...

  6. 创建maven web项目时,没有web.xml文件

    1.问题:创建maven项目时,选择的是创建web-app项目,但是结果配置之后,却没有web.xml文件. 2.解决办法: ------------------------------------- ...

  7. slider组件

    slider组件,是一个强大的滑动选择器组件: 属性: min:类型 数字 滑动选择器的(范围)最小值 max:类型 数字 滑动选择器的(范围)最大值 step:类型 数字 步长(滑一次走的距离)  ...

  8. 【adb真机查Log】Android Studio 3.X 找不到Android Device Monitor

    参考来源:https://blog.csdn.net/yuanxiang01/article/details/80494842 以下信息来源于Android Developers官网 Android设 ...

  9. str_shuffle函数

      str_shuffle() 函数打乱一个字符串,使用任何一种可能的排序方案.     <?php $str = 'hello world '; echo str_shuffle($str); ...

  10. Eclipse的switch workspace 选项中删除多余的workspace

    方法1 Eclipse图形化工具: 打开Eclipse后,选择功能菜单里的Windows->Preferences->,弹出对话框后,选择General->Startup and S ...