日期:2014-05-20  浏览次数:20748 次

eclipse初次做hibernate实验
执行测试文件的时候报错
信息: Reading mappings from resource: com/bjsxt/hibernate/model/Student.hbm.xml
Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.hibernate.cfg.Configuration.xmlHelper from class org.hibernate.cfg.AnnotationConfiguration
测试文件:
public class StudentTest {
public static void main(String[] args) {
Student s = new Student();
s.setId(1);
s.setName("wang");
s.setAge(22);
Configuration cfg = new AnnotationConfiguration();
SessionFactory sf = cfg.configure().buildSessionFactory();
Session session = sf.openSession();
session.beginTransaction();
session.save(s);
session.getTransaction().commit();
session.close();

sf.close();
}
}

------解决方案--------------------