WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); wac.getBean("sessionFactory");