代码:
ClassPathResource resource =new ClassPathResource("bean.xml");
DefaultListableBeanFactory factory =new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader =new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(resource);
spring解析资源得到resourced对象,根据resource对象解析成document对象,根据document对象解析得到beanDefinition,并注册到 DefaultListableBeanFactory中即this.beanDefinitionMap.put(beanName, beanDefinition);
网友评论