What is XMLBeanFactory in Spring framework?

What is XMLBeanFactory in Spring framework?

The org.springframework.beans.factory.xml.XmlBeanFactory is a class that implements the BeanFactory interface. To create an XmlBeanFactory, pass a java.io.InputStream to the constructor. The InputStream will provide the XML to the factory. For example, the following code snippet uses a java.io.FileInputStream to provide a bean definition XML file to XmlBeanFactory.

    BeanFactory factory = new XmlBeanFactory(new FileInputStream(\"beans.xml\"));

To retrieve the bean from a BeanFactory, call the getBean() method by passing the name of the bean you want to retrieve.

    MyBean myBean = (MyBean) factory.getBean(\"myBean\");

By:Jalees
Date:2031-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher