title: Splitting applicationContext to multiple files
body: <p>What is the correct way to split Spring's configuration to multiple xml files?</p>
  
  <p>At the moment I have</p>
  
  <ul>
  <li><code>/WEB-INF/foo-servlet.xml</code></li>
  <li><code>/WEB-INF/foo-service.xml</code></li>
  <li><code>/WEB-INF/foo-persistence.xml</code></li>
  </ul>
  
  <p>My <code>web.xml</code> has the following:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;description&gt;Spring MVC Dispatcher Servlet&lt;/description&gt;
      &lt;servlet-name&gt;intrafest&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              /WEB-INF/foo-*.xml
          &lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
              /WEB-INF/foo-*.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  
  &lt;listener&gt;
      &lt;listener-class&gt;
          org.springframework.web.context.ContextLoaderListener
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  
  <p>The actual questions:</p>
  
  <ul>
  <li>Is this approach <em>correct/best</em>?</li>
  <li>Do I really need to specify the config locations both in the <code>DispatcherServlet</code> <em>AND</em> the <code>context-param</code> sections?</li>
  </ul>
  
  <p>What do I need to keep in mind to be able to reference beans defined in <code>foo-servlet.xml</code> from <code>foo-service.xml</code>? Does this have something to do with specifying <code>contextConfigLocation</code> in <code>web.xml</code>?</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>I'm using <em>Spring</em> framework 3.0. It's my understanding that I don't need to do resource importing like this:</p>
  
  <pre><code> &lt;import resource="foo-services.xml"/&gt; 
  </code></pre>
  
  <p>Is this a correct assumption?</p>