一,配置文件位于类路径下 例如下图的spring-dao.xml 在代码中: ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-dao.xml"); 在单元测试中: