package com.yichao.woo.spring.di.basic; import org.springframework.beans.factory.support.BeanDefinitionReader; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.FileSystemResource; public class XmlConfigWithBeanFactory { public static void main(String[] args) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); reader.loadBeanDefinitions(new FileSystemResource("src/main/resources/spring.xml")); HelloWorld helloWorld = (HelloWorld) beanFactory.getBean("helloWorld"); System.out.println(helloWorld.helloWorld()); } }