Exception in thread "main" org.hibernate.MappingException: An association from the table student refers to an unmapped class: com.test.model.Team
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1299)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1217)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)
at Test.Test.main(Test.java:18)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1299)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1217)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)
at Test.Test.main(Test.java:18)
自己找的答案了 列出来供大家参考
1,检查你的hibernate.cfg.xml文件中是否添加了 <mapping resource="xxxx.hbm.xml"/>
2,检查你的hibernate.cfg.xml文件中的相关联的两个<mapping resource=""/>的顺序,可能有其中一个需要引用另一个,但是另一个却还没有编译,就是说被用作外键的表要放在前面
3,检查你的*.hbm.xml文件名是否正确
4, 检查你的*.hbm.xml里面类全名
我错的原因是class里面多了个空格