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
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
相关文章推荐
- Exception in thread &quot;main&quot; org.hibernate.InvalidMappingException: Could not pars
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.pojo.User
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.hibernate.domain.User
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.mao.PersonSet
- Exception in thread "main" org.hibernate.MappingNotFoundException
- Velocity报错: Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException:
- Exception in thread "main" org.hibernate.MappingException: invalid configuration
- Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: XXX
- 学Hibernate报:Exception in thread "main" org.hibernate.LazyInitializationException: could not initiali
- Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- Exception in thread "main" org.hibernate.MappingException: Unknown entity:
- Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException
- Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User
- Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transa
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: org.model.Kcb
- org.hibernate.PropertyNotFoundException: Could not find a getter for id in class com.pb.dao.UserDao
- Exception in thread "main" org.hibernate.MappingException
- 异常:Exception in thread "main" java.lang.ClassNotFoundException: Student
- Exception in thread "main" org.hibernate.QueryException: illegal attempt to dereference collection