您的位置:首页 > 移动开发

Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com.xzhl.user.model/Stu

2015-05-07 19:54 411 查看
刚开始学习hibernate,在写一个Helloworld程序时,遇到了如下问题:

Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com.xzhl.user.model/Student.hbm.xml not found

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

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 hibernateTest.main(hibernateTest.java:16)

问题很清楚:找不到com.xzhl.user.model/Student.hbm.xml 这个文件,原因很简单:就是这个路径com.xzhl.user.model有问题,在hibernate.cfg.xml配置文件的中<mapping resource="">resource代表的是路径,而com.xzhl.user.model我是从Student实体类考过来的包名,因此会识别不出来。

解决方法:把com.xzhl.user.model中的点改成斜杠即可com/xzhl/user/model
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐