关于Caused by: org.hibernate.InvalidMappingException: Unable to read XML报错解析

*******************************************************
错误原因:当前正编辑的xml里面有错误而导致读取不到该文件
我在Department.hbm.xml文件中加了注释
<!--
<list name="emps">
<key column="dep_id"/>
  <!-- 记录顺序用order <list-index column="order" /> 这里缺少了注释的后半部分,因此要注意了,当要注释的时候,都要成对出现,要么取消该注释
 <!---->这个注释里面套注释MyEcplise会报错,去掉后面的部分MyEcplise是不报错了,但是运行的时候就报下面的错误了!!!!注意了



<list-index column="order" />
<one-to-many class="Employee"/>
</list>
-->
注释不成对引起的异常,不该不该!!


java.lang.ExceptionInInitializerError
at cn.itt.test.TestMany2One.add(TestMany2One.java:93)读取不到资源文件
..........
Caused by: org.hibernate.InvalidMappingException: Unable to read XML 读取不到 相应的xml文件
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:101)
at org.hibernate.cfg.Configuration.add(Configuration.java:513)
at org.hibernate.cfg.Configuration.add(Configuration.java:509)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:801)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2344)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2310)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2290)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2243)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
at cn.itt.utils.HibernateUtils.<clinit>(HibernateUtils.java:23)  cf.configure();
... 23 more
Caused by: org.dom4j.DocumentException: Error on line 22 of document  : The string "--" is not permitted within comments. Nested exception: The string "--" is not permitted within comments.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)
... 34 more

*******************************************************

找了半天终于解决了,这种不注意的低级错误!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值