Monthly Archives: July 2017

There are two Application Contexts in Spring MVC apps

The root context, normally seen as biz-layer context, is normally defined as "applicationContext.xml" and loaded by ContextLoaderListener. 

The other context, the web-layer one is normally defined as "mvc-servlet.xml" and loaded by DispatcherServlet.

The web-layer context  will inherit beans from the root one, Except  some processors such as PropertyConfigurator. As a result, you should define two PropertyConfigurators. One for the biz layer, the other for the web layer.   See https://stackoverflow.com/questions/11890544/spring-value-annotation-in-controller-class-not-evaluating-to-value-inside-pro 

You may argue that your system has only one PropertyConfigurator and things work fine.  In this case, it’s highly possible your web-layer context is scanning biz-layer classes,  in addition to the web-layer classes.  As a result, your biz-layer spring beans have been loaded twice, one by the  ContextLoaderListener, the other by DispatcherServlet.