---
title: "实例化Spring IoC容器的三种方法"
author: "zwh910621"
date: "2009-12-02T18:00:41Z"
tags: []
slug: "spring-ioc"
draft: false
lastmod: "2009-12-02T18:00:41Z"
id: 539425
url: "https://javaheart88.iteye.com/blog/539425"
---

实例化Spring IoC容器的三种方法  
Resource resource=new FileSystemResource("beans.xml");  
BeanFactory factory=new XmlBeanFactory(resource);

ClassPathResource resource=new ClassPathResource("beans.xml");  
BeanFactory factory=new XmlBeanFactory(resource);

ApplicationContext context=new ClassPathXmlApplicationContext(  
    new String\[]{"applicationContext.xml","applicationContext-part2.xml"});  
//BeanFactory factory=(BeanFactory)context;