title: @ComponentScan not working in test with spring-boot-starter-test
body: <p>I am attempting to test my <code>@Service</code> and <code>@Repository</code> classes in my project with spring-boot-starter-test and <code>@Autowired</code> is not working for the classes I'm testing. </p>
  
  <p>Unit test:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @ContextConfiguration(classes = HelloWorldConfiguration.class
  //@SpringApplicationConfiguration(classes = HelloWorldRs.class)
  //@ComponentScan(basePackages = {"com.me.sbworkshop", "com.me.sbworkshop.service"})
  //@ConfigurationProperties("helloworld")
  //@EnableAutoConfiguration
  //@ActiveProfiles("test")
  // THIS CLASS IS IN src/test/java/ AND BUILDS INTO target/test-classes
  public class HelloWorldTest {
  
      @Autowired
      HelloWorldMessageService helloWorldMessageService;
  
      public static final String EXPECTED = "je pense donc je suis-TESTING123";
  
      @Test
      public void testGetMessage() {
          String result = helloWorldMessageService.getMessage();
          Assert.assertEquals(EXPECTED, result);
      }
  }
  </code></pre>
  
  <p>Service:</p>
  
  <pre><code>@Service
  @ConfigurationProperties("helloworld")
  // THIS CLASS IS IN /src/main/java AND BUILDS INTO target/classes
  public class HelloWorldMessageService {
  
      private String message;
  
      public String getMessage() {
          return message;
      }
  
      public void setMessage(String  message) {
          this.message=message;
      }
  
  }
  </code></pre>
  
  <p>The commented class annotations on the unit test represent the various things I've tried to get this working. The test and the project packages are in the same package paths and the <code>@ComponentScan</code> works fine from my entry point (<code>@RestController</code> class with main method). The service <code>@ComponentScan</code>'s and <code>@Autowire</code>'s fine in my <code>@RestController</code> class in the src/main/java side, but does not in the test. I am required to add it again as a <code>@Bean</code> in my <code>@Configuration</code> class in order for <code>@Autowired</code> to work. The class is otherwise in scope just fine and I can reference and instantiate it just fine from the test. The problem appears to be that <code>@ComponentScan</code> does not appear to correctly traverse multiple entries in my test runner classpath, in this case /target/test-classes and /target/classes.</p>
  
  <p>The IDE I am using is IntelliJ IDEA 13.</p>
  
  <p><strong>UPDATE</strong> - here are HelloWorldRs and its config:</p>
  
  <pre><code>@RestController
  @EnableAutoConfiguration
  @ComponentScan
  public class HelloWorldRs {
  
      //    SPRING BOOT ENTRY POINT - main() method
      public static void main(String[] args) {
          SpringApplication.run(HelloWorldRs.class);
      }
  
      @Autowired
      HelloWorldMessageService helloWorldMessageService;
  
      @RequestMapping("/helloWorld")
      public String helloWorld() {
          return helloWorldMessageService.getMessage();
      }
  
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>@Configuration
  public class HelloWorldConfiguration {
  
      @Bean
      public Map&lt;String, String&gt; map() {
          return new HashMap&lt;&gt;();
      }
  
      // This bean was manually added as a workaround to the @ComponentScan problem
      @Bean
      public HelloWorldMessageService helloWorldMessageService() {
          return new HelloWorldMessageService();
      }
  
      // This bean was manually added as a workaround to the @ComponentScan problem
      @Bean
      public HelloWorldRs helloWorldRs() {
          return new HelloWorldRs();
      }
  }
  </code></pre>