Create Spring ApplicationContext from XML memory

Is there a way to create an ApplicationContext (or something else in Spring that you can use to execute getBean("beanName")) by passing in an XML file that is in memory? The only methods I could find include providing a file or directory.

+3
source share
1 answer

You can try:

import org.springframework.context.support.GenericXmlApplicationContext;

String xmlDef = "...";
ApplicationContext ctx = new GenericXmlApplicationContext(new InputStreamResource(new ByteArrayInputStream(xmlDef.getBytes("UTF-8"))))
+4
source

All Articles