Web-application context/ root application context and transaction manager setup

As explained in the documentation, every dispatcher servlet has its own application context, where you typically define controllers, view resolvers, etc., and which inherits (and can override beans) from a root application context, which typically contains data source definitions, middle tier services, etc.

The ContextLoaderListener, as its documentation explains, is used to to start up and shut down Spring’s root application context (from which the servlet contexts inherit).

It’s also useful when you want to use Spring for your middle tier, but you don’t want to use Spring MVC as your presentation layer. In this case, you only define a root application context using ContextLoaderListener.

Leave a Comment