hibernate中读取并解析映射文件,创建SessionFactory报错
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
at test.Test.add(Test.java:26)
at test.Test.main(Test.java:12)
Caused by: org.hibernate.MappingException: Association references unmapped class: mapping.Student
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2377)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2659)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1305)
at util.SessionUtil.<clinit>(SessionUtil.java:13)
... 2 more
这是怎么回事 --------------------编程问答-------------------- Student这个实体没有映射。hibernate配置文件里有<mapping resource="。。。。/Student.hbm.xml"/>吗?或者别的实体里应用Student是否把包名也带上了。 --------------------编程问答-------------------- references unmapped class: mapping.Student
关联的Student类没有被映射, 缺少映射文件或者路径匹配错误 --------------------编程问答-------------------- 1,看看有没有Student这个类;
2,再看Student.hbm.xml映文件,和类引入(Class="");
3,hibernate配置文件里有<mapping resource="。。。。/Student.hbm.xml"/>。
补充:Java , Java EE