读书人

实例化bean的两种模式

发布时间: 2012-09-16 17:33:17 作者: rapoo

实例化bean的两种方式

?

实例化Spring容器常用的两种方式:(可以指定多个,可以通过string数组传入)

方式一:

在类路径下寻找配置文件实例化容器

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

方式二:

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

Application ctx = new FileSystemXmlApplication(new String[]{"d:\\bean.xml"})

读书人网 >软件架构设计

热点推荐