Use the approach outlined here. With one additional step, pass the DefaultListableBeanFactory
into a GenericApplicationContext
(this one has been around since Spring 1.1 and the GenericXmlApplicationContext is basically a convenience class doing more or less the same as in that blog post).
So something like this should work
String content = ...
GenericApplicationContext ctx = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
reader.loadBeanDefinitions(new ByteArrayResource(content.getBytes()));
ctx.refresh();
The ApplicationContext
should now be ready for use.