ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
//BeanFactory 的子类
XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("Beans.xml"));
//ApplicationContext接口,常用的接口实现FileSystemXmlApplicationContext,ClassPathXmlApplicationContext,WebXmlApplicationContext
ApplicationContext context = new FileSystemXmlApplicationContext("C:/Users/ZARA/workspace/HelloSpring/src/Beans.xml");
<bean id="..." class="..." init-method="..." scope="...">
</bean>
bean的作用域:singleton单例,prototype多例,request,session,global-session
bean的生命周期:bean的建立,Setter注入,BeanNameAware的setBeanName(),BeanFactoryAware的setBeanFactory(),BeanPostProcessors的processBeforeInitialization(),InitializingBean的afterPropertiesSet(),Bean定义文件中定义init-method,BeanPostProcessors的processAfterInitialization(),DisposableBean的destroy(),Bean定义文件中定义destroy-method
转载于:https://my.oschina.net/900quan/blog/629742