初学者开发的第一个Hibernate,如下错误%%%% Error Creating SessionFactory %%%%,求解

%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: component class not found: vo.UserId
at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:155)
at org.hibernate.tuple.AbstractComponentTuplizer.(AbstractComponentTuplizer.java:40)
at org.hibernate.tuple.PojoComponentTuplizer.(PojoComponentTuplizer.java:43)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:126)
at org.hibernate.mapping.Component.getType(Component.java:160)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.RootClass.validate(RootClass.java:193)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
at org.HibernateSessionFactory.(HibernateSessionFactory.java:31)
at test.Test.main(Test.java:17)
Caused by: java.lang.ClassNotFoundException: vo.UserId
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
... 11 more
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: vo/User.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at org.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at test.Test.main(Test.java:17)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping vo.User
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 8 more
Exception in thread "main" java.lang.NullPointerException
at test.Test.main(Test.java:18)

2个回答

配置文件出错

Could not read mappings from resource: vo/User.hbm.xml

读不到XML

component class not found: vo.UserId 这个类找不到 或者你的配置文件找不到

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问