网上出现这个问题的

lei.hbm.xml配置写错的,文件头应该改为如下,并不是这个问题

  1. <?xml version="1.0"?>
  2. <!DOCTYPE hibernate-mapping PUBLIC
  3. "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  4. "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

也有说

hibernate-mapping package 这里没加包名的.也不是,我加了

  1. <hibernate-mapping package="com.hs.model ">

奇葩问题,在class name上边加上包名解决

类.hbm.xml配置文件结构如下

代码中加粗的地方,最好加上包名,不然容易出奇葩问题

  1. <!-- 映射文件的根节点 -->
  2. <hibernate-mapping >
  3. <!--
  4. 对象关系映射的开始:class元素表示类和数据库中的表的映射关系。
  5. name属性指定持久化类(或者接口)的Java全限定名;
  6. table属性指定要映射的对应的数据库表名,如果省略,则以name作为表名
  7. -->
  8.  
  9. <class name="com.hs.model.StudentModel" table="table_student">
  10. <!--
  11. 持久化类对象的对象标识符(OID)和表的主键的映射关联:
  12. name属性指定类中作为OID的属性名;
  13. column属性表中主键字段的名字;如果省略,则以name作为字段名
  14. -->
  15.  
  16. <id name="id" column="id">
  17. <!-- 指定对象标识符生成器:class属性指定生成器的类别名 -->
  18.  
  19. </id>
  20. <!--
  21.  
  22. 普通属性的映射:
  23. name属性:属性的名字,以小写字母开头;
  24. column属性:对应的数据库字段名.如果省略,则以name作为字段名
  25. type属性:指定Hibernate的映射类型、如果省略,则自动匹配
  26. -->
  27. <property name="username" column="username"/>
  28. <property name="password" column="password" />
  29. </class>
  30.  
  31. </hibernate-mapping>

Could not parse mapping document from resource com/hs/model/StudentModel.hbm.xml的更多相关文章

  1. Could not parse mapping document from resource cn/spt/model/Student.hbm.xml

    初始hibernate, 写第一个程序 helloworld的错误: Exception in thread "main" org.hibernate.InvalidMapping ...

  2. 错误/异常:org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/shore/model/Husband.hbm.xml 的解决方法

    1.错误/异常视图 错误/异常描述:无效的映射异常,无法从xxxxx资源中解析映射文档 2.解决方法     出现这个异常,一般情况下是包名写错了.改回来即可. 看报错/异常的第一行,最后面,会提示你 ...

  3. 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 ...

  4. Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource Caused by: org.hibernate.DuplicateMappingException: duplicate import: Person refers to both cn.itcast.

    此错误是说有两个相同的名字的配置文件,所以不知道查找哪个.解决方法就是把不需要的那个配置文件删除. 删除mapping中不需要的那个xml文件即可

  5. InvalidMappingException提示Could not parse mapping document错误的解决方法

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

  6. Could not parse mapping document from input stream hibernate配置异常

    十二月 , :: 下午 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context ...

  7. 关于hibernate总是报错 配置factory的id找不到,mapping配置文件Could not parse mapping document from input stream

    Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream ...

  8. Could not parse mapping document from input stream

    无法从输入流解析映射文档 1.定义的类名或属性名不对,如:*.hbm.xml文件中属性name对应的实体类name不一致.2.xml头文件中"http://www.hibernate.org ...

  9. org.hibernate.InvalidMappingException: Could not parse mapping document from无法创建sessionFactory

    把 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" 改为 "http://hibernate.sourc ...

随机推荐

  1. Python-基本运算符与流程控制

    目录 基本运算符 算术运算符 比较运算符 赋值运算符 逻辑运算符 身份运算符 位运算符 成员运算符 运算符优先级 流程控制 if 判断 单分支结构 双分支结构 多分支结构 while 循环 while ...

  2. SQLite C++ Wrapper 是一个 C++ 语言对 SQLite 的最小封装包。

    SQLite C++ Wrapper 是一个 C++ 语言对 SQLite 的最小封装包. 示例代码1:   #include <string> #include <iostream ...

  3. C# FTP上传下载(支持断点续传)

    <pre class="csharp" name="code"><pre class="csharp" name=&quo ...

  4. 84 落单的数 III

    原题网址:http://www.lintcode.com/zh-cn/problem/single-number-iii/# 给出2*n + 2个的数字,除其中两个数字之外其他每个数字均出现两次,找到 ...

  5. 7 Serialize and Deserialize Binary Tree 序列化及反序列化二叉树

    原题网址:http://www.lintcode.com/zh-cn/problem/serialize-and-deserialize-binary-tree/# 设计一个算法,并编写代码来序列化和 ...

  6. System.Web.Mvc.HttpNotFoundResult.cs

    ylbtech-System.Web.Mvc.HttpNotFoundResult.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, ...

  7. Origin使用自定义函数拟合曲线函数

    (2019年2月19日注:这篇文章原先发在自己github那边的博客,时间是2016年10月28日) 最近应该是六叔的物化理论作业要交了吧,很多人问我六叔的作业里面有两道题要怎么进行图像函数的拟合.综 ...

  8. Lua语言入门

    (摘自Lua程序设计) Lua语言中的标识符(或名称)是由任意字母丶数字和下划线组成的字符串(注意不能以数字开头) 下划线加大写字母组成的标识符通常被Lua语言用作特殊用途,应避免将其用作其他用途. ...

  9. wc,sort,uniq,awk,grep

    wc awk, sort, uniq grep

  10. hibernate和jdbc的区别 优缺点

    JDBC与Hibernate在性能上相比,JDBC灵活性有优势.而Hibernate在易学性,易用性上有些优势.当用到很多复杂的多表联查和复杂的数据库操作时,JDBC有优势. 相同点: ◆两者都是JA ...