Role:
1. The beanfactory is responsible for reading the bean configuration document, managing the bean's loading, instantiating, maintaining the dependency between the beans, and responsible for the bean's declaration cycle.
2. ApplicationContext provides more complete framework functionality in addition to the functionality provided by the beanfactory above:
A. Internationalization support
B. Resource access: Resource rs = ctx. GetResource ("Classpath:config.properties"), "File:c:/config.properties"
C. Event delivery: By implementing the Applicationcontextaware interface
3. Common ways to get ApplicationContext:
Filesystemxmlapplicationcontext: Created from a file system or URL-specified XML configuration file with an array of configuration file names or file names
Classpathxmlapplicationcontext: Created from the classpath XML configuration file, you can read the configuration file from the jar package
Webapplicationcontextutils: Reading a configuration file from the Web application's root directory requires a configuration in XML. config, which can be configured with a listener or servlet to implement
<Listener><Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class></Listener><servlet><Servlet-name>Context</Servlet-name><Servlet-class>Org.springframework.web.context.ContextLoaderServlet</Servlet-class><Load-on-startup>1</Load-on-startup></servlet>
Either way, the default profile is Web-inf/applicationcontext.xml, or you can use Context-param to specify the configuration file
< Context-param > < Param-name >contextconfiglocation</param-name><Param-value >/web-inf/myapplicationcontext.xml</param-value> </ Context-param >
What are the roles and differences between Beanfactory and ApplicationContext in spring?