Hibernate配置文件不正确?

时间:2013-04-17 10:00:16

标签: java xml hibernate

earlier post中,我的hibernate配置文件存在一些未知问题。一个人给了我另一个配置文件使用,并解决了旧的配置错误。但它也引入了一个新的错误,如下所示。我该如何解决?

修改

org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
[main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
[main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
[main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
[main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
[main] INFO org.hibernate.cfg.Configuration - configuring from resource:
 /hibernate.cfg.xml
[main] INFO org.hibernate.cfg.Configuration - Configuration resource: 
/hibernate.cfg.xml
[main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : 
com/xx  /portal/db/User.hbm.xml
Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com/xx
/portal/db/User.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:610)
at org.hibernate.cfg.AnnotationConfiguration.addResource
(AnnotationConfiguration.java:912)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement
(AnnotationConfiguration.java:617)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure
(AnnotationConfiguration.java:1002)
at    org.hibernate.cfg.AnnotationConfiguration.doConfigure
(AnnotationConfiguration.java:69)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure
(AnnotationConfiguration.java:990)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure
(AnnotationConfiguration.java:69)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
at org.hibernate.cfg.AnnotationConfiguration.configure
(AnnotationConfiguration.java:972)
at org.hibernate.cfg.AnnotationConfiguration.configure
(AnnotationConfiguration.java:69)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.AnnotationConfiguration.configure
(AnnotationConfiguration.java:966)
at com.examscam.model.User.persist(User.java:45)
at com.examscam.model.User.main(User.java:55) 

我删除了“! - 禁用缓存 - ”“! - UTF8到数据库 - ”“! - 实体映射 - ”现在我收到了一个新错误。

3 个答案:

答案 0 :(得分:0)

com/xx/portal/db/User.hbm.xml未找到

你真的有这个包名com/xx

检查上述路径中是否有User.hbm.xml。如果没有,则删除此条目。

<mapping resource="com/xx/portal/db/User.hbm.xml" />

答案 1 :(得分:0)

如果您没有任何实体映射文件,请先删除行<mapping resource="com/xx/portal/db/User.hbm.xml" />

答案 2 :(得分:0)

从配置xml中删除波纹管线,如果已定义任何hbms

,则替换
   <!-- Entity Mappings -->
   <mapping resource="com/xx/portal/db/User.hbm.xml" />