I have a spring dispatcher servlet with servlet-name \"spring-mvc\". The spring-mvc-servlet.xml appears as follows:
You can load your contexts hierarchically so that context described in annotation-context.xml
becomes a parent of your Spring MVC context. The latter will then be able to access all the beans defines in the former.
Spring documenation describes several ways to do it. For example, in your web.xml
:
// load parent context
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/annotation-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
// load Spring MVC context
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>