ClassPathXmlApplicationContext Example
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
ErrorHandler handler = (ErrorHandler) context.getBean("errHandler");
handler.showError();
|
Define
Application context is used to load and wire bean object reads from xml configuration file.
Application xml file can read by three different classes in spring framework.
1) ClassPathXmlApplicationContext
2) FileSystemXmlApplicationContext
3) XmlWebApplicationContext
ClassPathXmlApplicationContext
ClassPathXmlApplicationContext used to reads a xml from classes path.
FileSystemXmlApplicationContext
FileSystemXmlApplicationContext used to reads a xml from machine path of the file.
XmlWebApplicationContext
XmlWebApplicationContext used to reads a xml from a internet web location.
|