It is easily to know how many contexts have been created if we create ApplicationContext instances programmatically. However, how many context are created if we use ContextLoaderListener? For example Spring’s reference as below:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
It has 2 context xml files. Does it means 2 contexts are created?
Thanks.
ContextLoaderListenercreates only one application context containing all beans from files selected incontextConfigLocation. Bean definitions are merged together and form a single context.However if you use Spring MVC, the framework will create one extra child context per each
DispatcherServlet.