title: Spring MVC in a multi maven module project
body: <p>I am designing and implementing a Java web application using Spring, Spring MVC and Maven. My goal is to create three modules:</p>
  
  <ul>
  <li>a data module containing entities and DAOs</li>
  <li>a service module containing the business logic and the @Service classes</li>
  <li>a web module containing jsp files and the @Controller classes</li>
  </ul>
  
  <p>Communications between the service module and the data module work great. The service module depends on the data module and it includes the data module with <code>&lt;import resource="dataApplicationContext.xml"/&gt;</code> in serviceApplicatioContext.xml. I have tested it with a static main class and some integration tests.</p>
  
  <p>The problem I am having is about making the web module to depend on the service module. How do I make my mvc-dispatcher-servlet.xml import my serviceApplicatioContext.xml? </p>
  
  <p>Solution I have tried so far:
  1)If I just use <code>&lt;import resource="/serviceApplicationContext.xml"/&gt;</code> then Spring MVC would look for /WEB-INF/serviceApplicationContext.xml which, of course, does not exist.</p>
  
  <p>2)If I replace <code>&lt;context:component-scan base-package="my.project.controller" /&gt;</code> with <code>&lt;context:component-scan base-package="my.project" /&gt;</code> then Spring does not kick in and no hibernate session is created.</p>
  
  <p>Thanks a lot,
  Alex</p>