spring
1.ClassPathXmlApplicationContext
使用绝对路径需要添加file前缀
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{
" file:D:/MyEclipse/studyspaces/webpro/WebRoot/WEB-INF/conf/applicationContext.xml"});
使用相对路径只能读放在WEB-INF/classes目录下的配置文件,也就是类根目录
ApplicationContext ctx = new ClassPathXmlApplicationContext(" classpath:appcontext.xml");
ApplicationContext factory = new ClassPathXmlApplicationContext("appcontext.xml");
1.ClassPathXmlApplicationContext
使用绝对路径需要添加file前缀
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{
" file:D:/MyEclipse/studyspaces/webpro/WebRoot/WEB-INF/conf/applicationContext.xml"});
使用相对路径只能读放在WEB-INF/classes目录下的配置文件,也就是类根目录
ApplicationContext ctx = new ClassPathXmlApplicationContext(" classpath:appcontext.xml");
ApplicationContext factory = new ClassPathXmlApplicationContext("appcontext.xml");