欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

IOC容器实例化 博客分类: spring IOCSpringXML 

程序员文章站 2024-03-16 09:48:58
...
方式1:
---------------
org.springframework.core.io.Resource resource = new org.springframework.core.io.FileSystemResource(
				"com/spring/mapping/applicationContext.xml");
		org.springframework.beans.factory.BeanFactory beanfactory = new org.springframework.beans.factory.xml.XmlBeanFactory(
				resource);


方式2:
---------------
org.springframework.core.io.ClassPathResource resource=new org.springframework.core.io.ClassPathResource("com/spring/mapping/applicationContext.xml");
		org.springframework.beans.factory.BeanFactory beanfactory = new org.springframework.beans.factory.xml.XmlBeanFactory(
				resource);


方式3:
---------------
org.springframework.context.ApplicationContext context=new org.springframework.context.support.ClassPathXmlApplicationContext("com/spring/mapping/applicationContext.xml");
		org.springframework.beans.factory.BeanFactory beanfactory=(org.springframework.beans.factory.BeanFactory)context;
相关标签: IOC Spring XML