第1关:Spring配置文件加载对象

题解代码:

package step1;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Task {

	public void getCar(){
		ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext1.xml");
		Car car = (Car)app.getBean("car");
		car.run();
	}

}

发布了53 篇原创文章 · 获赞 16 · 访问量 9247

猜你喜欢

转载自blog.csdn.net/Zheng_lan/article/details/105713538