首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

实例化Spring器皿的两种常用方法

2012-11-03 
实例化Spring容器的两种常用方法实例化Spring容器常用的两种方式:方法一:在类路径下寻找配置文件来实例化

实例化Spring容器的两种常用方法
实例化Spring容器常用的两种方式:
方法一:
在类路径下寻找配置文件来实例化容器
ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"beans.xml"});

方法二:
在文件系统路径下寻找配置文件来实例化容器
ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[]{“d:\\beans.xml“});
注意Spring的配置文件可以指定多个,可以通过String数组传入。

热点排行