ApplicationContext ctx = new ClassPathXmlApplication("applicationContext.xml"); DataSource ds = (DataSource)ctx.getBean("dataSource");