title: Spring Testing with JUnit4 Runner does not work after trying different solutions
body: <p>When autowiring my spring test class with the JUnit4 Test Runner the context startup yields the following exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mypackage.TestClass': Injection of autowired dependencies failed; 
  nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mypackage.ServiceClass com.mypackage.TestClass.service; 
  nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.mypackage.ServiceClass] 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></pre>
  
  <h2>My Setup</h2>
  
  <p>The <code>TestClass</code> is annotated as followed</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = {"classpath:spring/testContext.xml"})
  </code></pre>
  
  <p>The autowired fields are annotated like this</p>
  
  <pre><code> @Autowired
   ACrudRepository repository; // is autowired
  
   @Autowired
   @Qualifier("service")
   ServiceClass service; // is NOT autowired
  </code></pre>
  
  <p>The <code>testContext.xml</code> has the following Bean definition (and some more):</p>
  
  <pre><code>&lt;bean class="com.mypackage.ServiceClass" id="service"&gt;
      &lt;property name="someBoolean" value="false"/&gt;
      &lt;property name="otherBoolean" value="false"/&gt;
      &lt;property name="someList"&gt;
        &lt;list&gt;&lt;value&gt;withOneValue&lt;/value&gt;&lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;jpa:repositories base-package="com.mypackage"/&gt;
  </code></pre>
  
  <p><strong>What I have tried:</strong></p>
  
  <ul>
  <li><code>@Qualifier("service")</code></li>
  <li>Checked <a href="https://stackoverflow.com/questions/39173982/what-is-a-nosuchbeandefinitionexception-and-how-do-i-fix-it">What is a NoSuchBeanDefinitionException and how do I fix it?</a></li>
  <li>Checked <a href="https://stackoverflow.com/questions/32703286/nosuchbeandefinitionexception-using-autowired-in-spring-test">NoSuchBeanDefinitionException using @Autowired in spring test</a></li>
  <li>added <code>&lt;component-scan&gt;</code> in xml with <code>@Service/@Component</code> on <code>ServiceClass</code></li>
  <li>added <code>@ComponentScan</code> on <code>TestClass</code></li>
  </ul>