实例化spring容器

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

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

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

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

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

肆虐的海水
原文地址:https://www.cnblogs.com/ckysea/p/4526501.html