title: Spring Boot: "No qualifying bean of type... found" when autowiring concrete class
body: <p>I am writing a component using Spring Boot and Spring Boot JPA. I have a setup like this:</p>
  
  <p>The interface:</p>
  
  <pre><code>public interface Something {
      // method definitions
  }
  </code></pre>
  
  <p>The implementation:</p>
  
  <pre><code>@Component
  public class SomethingImpl implements Something {
      // implementation
  }
  </code></pre>
  
  <p>Now, I have a JUnit test which runs with <code>SpringJUnit4ClassRunner</code>, and I want to test my <code>SomethingImpl</code> with this.</p>
  
  <p>When I do</p>
  
  <pre><code>@Autowired
  private Something _something;
  </code></pre>
  
  <p>it works, but</p>
  
  <pre><code>@Autowired
  private SomethingImpl _something;
  </code></pre>
  
  <p>causes the test to fail throwing a <code>NoSuchBeanDefinitionException</code> with the message <code>No qualifying bean of type [com.example.SomethingImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}</code></p>
  
  <p>But in the test case, I want to <em>explicitly</em> inject my <code>SomethingImpl</code> because it is the class I want to test. How to I achieve this?</p>