Spring 手动加载XML配置的bean

DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
xmlBeanDefinitionReader.setValidationMode(3);
//inputStream为读取到XML中每个Bean元素的输入流,可参考Camunda中的BeansConfigurationHelper类
Resource springResource = new InputStreamResource(inputStream)'
xmlBeanDefinitionReader.loadBeanDefinitions(springResource);
//ProcessEngineConfigurationImpl 加载后的类
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)beanFactory.getBean(beanName);

你可能感兴趣的:(Spring 手动加载XML配置的bean)