spring中读取spring.XML文件的方法



一:FileSystemXmlApplicationContext读取的是XML的位置不在classpath下在利web-inf下所以需要真时路径

LookerManager lookerManager= (LookerManager) new FileSystemXmlApplicationContext

(“D:\\idea\\spring+springmvc+hibernate\\web\\WEB-INF\\applicationContext.xml”).

getBean(“lookerManager”);

二:ClassPathXmlApplicationContext()读取的是classpath(直接在src下)下的xml

new ClassPathXmlApplicationContext

(“applicationContext.xml”).