0

较早的帖子中,我的休眠配置文件有一些未知问题。一个人给了我另一个配置文件来使用,它解决了旧的配置错误。但它也引入了一个新错误,如下所示。我如何解决它 ?

编辑

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到数据库--”“!--实体映射--”,现在我收到一个新错误。

4

3 回答 3

0

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

于 2013-04-17T10:06:02.583 回答
0

如果您定义了任何 hbms,请从您的配置 xml 中删除波纹管或替换

   <!-- Entity Mappings -->
   <mapping resource="com/xx/portal/db/User.hbm.xml" />
于 2013-04-17T10:06:39.510 回答
0

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

你真的有这个包名吗com/xx

检查您是否User.hbm.xml在提到的路径中有一个。如果没有,则删除此条目。

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

于 2013-04-17T10:03:53.907 回答