你的工程是自动编译的吗?把这个类考到你的程序里然后hibernate.cfg.xml放到src下试试importorg.hibernate.Session;importorg.hibernate.SessionFactory;importorg.hibernate.cfg.Configuration;publicclassHibernateUtils{privatestaticSessionFactorysessionFactory;publicstaticSessionFactorygetSessionFactory(){returnsessionFactory;}publicHibernateUtils(){}static{Configurationcfg=newConfiguration();cfg.configure();sessionFactory=cfg.buildSessionFactory();}publicstaticSessiongetSession(){returnsessionFactory.openSession();}publicstaticvoidmain(String[]args){sessionFactory=HibernateUtils.getSessionFactory();System.out.println(sessionFactory);}}