title: How to reference another project in eclipse for spring 3.1 autowiring?
body: <p>I'm using tomcat 6x, spring 3.1 with annotations, cxf 2.2x.  I have a web service project, lets call it wsproject that I have referenced in my main project, lets call that myproject.  I added a project reference for wsproject to myproject using the configurebuildpath in eclipse.  I have everything working and I'm able to go from the main project to the code in the web service project.  </p>
  
  <p>Now however, when I try to autowire a service, like myservice from wsproject into the controller, for example, mycontroller in myproject, spring throws this error:  </p>
  
  <p><strong>No matching bean of type [com.service.MyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}</strong></p>
  
  <p>I have this in the servlet-context.xml:</p>
  
  <pre><code>&lt;annotation-driven /&gt;
  ...
  &lt;context:annotation-config/&gt;
  &lt;context:component-scan base-package="com.myproject" /&gt;
  
  
   &lt;beans:import resource="classpath*:/WEB-INF/spring/serviceServlet/service-context.xml"/&gt;
  &lt;context:component-scan base-package="com.service.myService"/&gt;  
  
  &lt;beans:bean id="myService" class="com.service.myServiceImpl"&gt;
      &lt;beans:property name="myService" ref="myService" /&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>and in the MyController class I have:</p>
  
  <pre><code>@Controller
  public class MyController {
      @Autowired
      private MyService myService;
  ...
  </code></pre>
  
  <p>and on the service I have:</p>
  
  <pre><code> @Service
      @WebService(targetNamespace = "http://...")
      public interface MyService {
  
  //more methods ...
  </code></pre>
  
  <p>but it seems like Spring can't find the other project for some reason.  So when I start up the app I get this error when it loads.  Any ideas what is wrong here? </p>
  
  <p>I did import the project into STS and under the spring explorer I could see that this additional service-context wasn't loaded, so that seems to be the root issue of the problem.  Something isn't configured correctly here.</p>
  
  <p><strong>Aftermath:</strong></p>
  
  <p>I wasn't actually pointing to the code in the second project, even though eclipse appeared to be using it. When I removed the original war dependency in maven, compile errors showed up.  So even though eclipse was stopping on breakpoints in the service project, that code wasn't actually running.  I have no idea how that could be, but it was.  </p>
  
  <p>So, I removed the service project as a reference to the client project, packaged it up as a war and ran it on tomcat. That solved my referencing issues.</p>