title: Spring boot dependency injection of an interface
body: <p>I have 2 spring boot microservice let's say core and persistence. where persistence has a dependency on core.</p>
  <p>I have defined an interface in core whose implementation is inside persistence as below:</p>
  <p><strong>core</strong></p>
  <pre class="lang-java prettyprint-override"><code>package com.mine.service;
  public interface MyDaoService {
  }
  </code></pre>
  <p><strong>Persistence</strong></p>
  <pre class="lang-java prettyprint-override"><code>package com.mine.service.impl;
  @Service
  public class MyDaoServiceImpl implements MyDaoService {
  }
  </code></pre>
  <p>I am trying to inject MyDaoService in another service which is in core only:</p>
  <p><strong>core</strong></p>
  <pre class="lang-java prettyprint-override"><code>package com.mine.service;
  @Service
  public class MyService {
  
  private final MyDaoService myDaoService;
  
      public MyService(MyDaoService myDaoService) {
          this.myDaoService = myDaoService;
      }
  }
  </code></pre>
  <p>while doing this i am getting this weird error:</p>
  <pre><code>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Parameter 0 of constructor in com.mine.service.MyService required a bean of type 'com.mine.service.MyDaoService' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'com.mine.service.MyDaoService' in your configuration.
  </code></pre>
  <p>can anyone explain me why ?</p>
  <p>NOTE: i have already included com.mine.service in componentscan of springbootapplication as below</p>
  <pre class="lang-java prettyprint-override"><code>package com.mine.restpi;
  @SpringBootApplication
  @EnableScheduling
  @ComponentScan(basePackages = &quot;com.mine&quot;)
  public class MyRestApiApplication {
  public static void main(String[] args) {
          SpringApplication.run(MyRestApiApplication.class, args);
      }
  }
  </code></pre>