Is there a way to create an ApplicationContext (or whatever else in Spring you can use to do getBean("beanName") ) by passing in an XML file that is in memory? The only methods I've been able to find involve providing a file or directory.
1 Answer
You could give it a try:
import org.springframework.context.support.GenericXmlApplicationContext;
String xmlDef = "...";
ApplicationContext ctx = new GenericXmlApplicationContext(new InputStreamResource(new ByteArrayInputStream(xmlDef.getBytes("UTF-8"))))
1 Comment
Malcolm O'Hare
This got me to the actual solution, thanks!
new GenericXmlApplicationContext(new ByteArrayResource(xmlDef.getBytes("UTF-8")))