beanFactory 和 applicetion区别

beanFactory:

public void testIOC1() throws Exception{  
        Resource resource =new ClassPathResource("cn/spy/first/applicationContext.xml");  
        @SuppressWarnings("deprecation")  
        BeanFactory factory =new XmlBeanFactory(resource);  
        User user =(User) factory.getBean("user");  
        System.out.println(user.getId()+" : "+user.getUsername());  
          
}  

Applicetion

public void testIOC2() throws Exception{  
        ApplicationContext context= new ClassPathXmlApplicationContext("cn/spy/first/applicationContext.xml");  
        System.out.println("-----容器创建完成-----");  
        User user =(User) context.getBean("user");  
        System.out.println(user.getId()+" : "+user.getUsername());  
}
今日事今日毕
原文地址:https://www.cnblogs.com/gjack/p/8655714.html