手动加载spring配置文件

分配置文件在classpath下和web-inf下两种情况的加载:

ApplicationContext context = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/applicationContext.xml");
new ClassPathXmlApplicationContext("applicationContext.xml");// 从classpath中加载
new FileSystemXmlApplicationContext("classpath:地址");// 没有classpath表示当前目录


注解加载
@org.springframework.test.context.ContextConfiguration(locations={"file:WebRoot/WEB-INF/applicationContext.xml"})

@org.springframework.test.context.ContextConfiguration(locations={"classpath:applicationContext.xml"})


地址:http://jie66989.iteye.com/blog/1699622

你可能感兴趣的:(spring)