日期:2014-05-19 浏览次数:20670 次
//applicationContext.xml为你的配置文件,默认在src目录下 ApplicationContext contex = new ClassPathXmlApplicationContext("applicationContext.xml"); SessionFactory factory = (SessionFactory)contex.getBean("sessionFactory"); //sessionFactory 为你配置的SessionFactory been的id Session session = factory.openSession();