1.需要基本jar包
知识点:基本知识点
如何创建一个对象,通过xml配置
1
| <bean id=”beanService” class=”com.bean.service.beanServiceImpl”></bean>
|
其中beanservice是接口,beanServiceImpl是实现类
面试题:spring容器在什么时候创建
spring容器在xml加载时,就创建对象
test测试的方法(说明了ClassPathXmlApplicationContext,FileSystemXmlApplicationContext的差别)
1 2 3 4 5 6 7 8 9 10
| @Test public void test() { ApplicationContext applicationContext=new FileSystemXmlApplicationContext(“ApplicationContext.xml”); beanService beanService=(com.bean.service.beanService) applicationContext.getBean(“beanService”); beanService.add(); beanService.update(); }
|