实例化spring容器

方法一:在类路径下寻找配置来实例化容器

 1 ApplicationContext ctx = new ClassPathXmlApplicationContext( 2 new String[]{"beans.xml"}); 

方法二:在文件系统路径下寻找配置文件来实例化容器

 1 ApplicationContext ctx = new FileSystemXmlApplicationContext( 2 new String[]{"d:\\beans.xml"}); 

Spring的配置文件可以指定多个,通过string数组传入

posted @ 2015-05-24 21:19  别闹了  阅读(1169)  评论(0编辑  收藏  举报