title: How does the @Autowired interface, which extends CrudRepository, works? I would like to have some insights
body: <p>Suppose my interface extends CrudRepository as follows</p>
  
  <pre><code> @Repository
      public interface EmployeeRepository extends CrudRepository&lt;Employee, Integer&gt; 
      {
      }
  </code></pre>
  
  <p>and I use the EmployeeRepository  interface in my Service class as follows </p>
  
  <pre><code>@Service
  public class EmployeeService 
  {
  
   @Autowired 
    EmployeeRepository employeeRepository;
  
  
   public List&lt;Employee&gt; getAllEmployee()
   {
       List&lt;Employee&gt; listEmp=new ArrayList&lt;Employee&gt;();
       employeeRepository.findAll().forEach(listEmp::add);
       return listEmp;
  
  
   }
  }
  </code></pre>
  
  <p>and controller as follows</p>
  
  <pre><code>@RestController
  public class WelcomeController 
  {
      @Autowired
      EmployeeService empservice;
  
      @RequestMapping("/employees")
      public List&lt;Employee&gt; getEmployees()
      {
          return empservice.getAllEmployee();
      }
  
  }
  </code></pre>
  
  <p>and it gives the following exception</p>
  
  <p><strong>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'welcomeController': Unsatisfied dependency expressed through field 'empservice': Error creating bean with name 'employeeService': Unsatisfied dependency expressed through field 'employeeRepository'</strong></p>
  
  <p>The error is obvious because interface EmployeeRepository is not implemented by any class and </p>
  
  <pre><code>@Autowired  
  EmployeeRepository employeeRepository;
  </code></pre>
  
  <p>Autowired will fail because no class is implementing employeeRepository.</p>
  
  <p>Still, I am confused as to how it works as, every code I saw on GitHub and tutorial, works perfectly.</p>
  
  <p>Where am I going wrong and how does @Autowired work on the interface which extends CrudRepository, even though no class is implementing it; which is the basic rule of Autowiring? That is, if you are auto wiring any interface, at least one class has to implement that interface then and then Autowiring will be successful.</p>