使用xmlBeanFactory启动容器

public class BeanFactoryTest {
	public static void main(String[] args) throws Throwable{
	   ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
	   Resource res = resolver.getResource("classpath:com/smart/beanfactory/beans.xml");
	   System.out.println(res.getURL());
       BeanFactory bf = new XmlBeanFactory(res);
       System.out.println("init BeanFactory.");
       
       Car car = bf.getBean("car",Car.class);
       System.out.println("car bean is ready for use!");
       car.introduce();
	}
}

你可能感兴趣的:(spring)