为了账号安全,请及时绑定邮箱和手机立即绑定

不知道错在哪里 都是看着视频坐的

%%%% Error Creating SessionFactory %%%%

org.hibernate.InvalidMappingException: Unable to read XML

at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)

at org.hibernate.cfg.Configuration.add(Configuration.java:478)

at org.hibernate.cfg.Configuration.add(Configuration.java:474)

at org.hibernate.cfg.Configuration.add(Configuration.java:647)

at org.hibernate.cfg.Configuration.addResource(Configuration.java:730)

at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2109)

at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2081)

at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2061)

at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2014)

at org.hibernate.cfg.Configuration.configure(Configuration.java:1929)

at org.hibernate.cfg.Configuration.configure(Configuration.java:1908)

at com.msl.util.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:32)

at com.msl.test.test1.main(test1.java:24)

Caused by: org.dom4j.DocumentException: http://hibernate.org/dtd/hibernate-mapping-3.0.dtd%20 Nested exception: http://hibernate.org/dtd/hibernate-mapping-3.0.dtd%20

at org.dom4j.io.SAXReader.read(SAXReader.java:484)

at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:78)

... 12 more

五月 08, 2016 2:50:42 下午 org.hibernate.cfg.Configuration configure

INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml

五月 08, 2016 2:50:42 下午 org.hibernate.cfg.Configuration getConfigurationInputStream

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml

五月 08, 2016 2:50:42 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: com/msl/entity/Student.hbm.xml

%%%% Error Creating SessionFactory %%%%

org.hibernate.InvalidMappingException: Unable to read XML

at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:109)

at org.hibernate.cfg.Configuration.add(Configuration.java:478)

at org.hibernate.cfg.Configuration.add(Configuration.java:474)

at org.hibernate.cfg.Configuration.add(Configuration.java:647)

at org.hibernate.cfg.Configuration.addResource(Configuration.java:730)

at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2109)

at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2081)

at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2061)

at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2014)

at org.hibernate.cfg.Configuration.configure(Configuration.java:1929)

at org.hibernate.cfg.Configuration.configure(Configuration.java:1908)

at com.msl.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:71)

at com.msl.util.HibernateSessionFactory.getSession(HibernateSessionFactory.java:55)

at com.msl.test.test1.main(test1.java:24)

Caused by: org.dom4j.DocumentException: http://hibernate.org/dtd/hibernate-mapping-3.0.dtd%20 Nested exception: http://hibernate.org/dtd/hibernate-mapping-3.0.dtd%20

at org.dom4j.io.SAXReader.read(SAXReader.java:484)

at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:78)

... 13 more


正在回答

3 回答

检查下对应的Grade和Student映射文件,看是否导入的.dtd文件后面多了一个空格  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"

0 回复 有任何疑惑可以回复我~

你的mapping没有被正确的读出,两个可能:

1,你的hibernate包的版本不正确

2,你的cfg.xml文件的编辑有错

0 回复 有任何疑惑可以回复我~

好像是jdbc驱动打问题,你自己加个jdbc驱动试试

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Hibernate初探之一对多映射
  • 参与学习       42171    人
  • 解答问题       295    个

Hibernate中一对多关联映射配置,以及cascade和inverse属性作用

进入课程

不知道错在哪里 都是看着视频坐的

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信