Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext路径问题

2014-11-24 08:26:44 · 作者: · 浏览: 0
/*
//ApplicationContext ctx=new FileSystemXmlApplicationContext("src/main/resources/spring.xml");
ApplicationContext ctx=new FileSystemXmlApplicationContext("file:e:/lib/spring.xml");
Car car=(Car)ctx.getBean("car1");
System.out.println(car.getName()+"\n"+car.getPrice());
*/

//BeanFactory bf=new ClassPathXmlApplicationContext("spring.xml");
BeanFactory bf=new ClassPathXmlApplicationContext("file:e:/lib/spring.xml");
Car car=(Car)bf.getBean("car1");
System.out.println(car.getName()+"\n"+car.getPrice());
作者:wodwl