执行hibernate时出现异常,求救啦
错误提示如下:
java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V
我的代码如下:不知道是不是版本问题呢,这段代码在eclipse中运行没有异常的
public static void main(String[] args) {
addGrade();
}
//将学生添加到班级
public static void addGrade()
{
Grade g=new Grade("java","软件开发一班");
Student stu=new Student("张三","男");
Student stu1=new Student("穆女生","女");
//
g.getStudents().add(stu);
g.getStudents().add(stu1);
//创建hibernate内置对象
Configuration config=new Configuration().configure();
//创建服务注册对象
ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
//创建sessionfactory对象
SessionFactory sessionFactory=config.buildSessionFactory();
Session session=sessionFactory.openSession();
Transaction tx=session.beginTransaction();
session.save(g);
tx.commit();
session.close();
sessionFactory.close();
}