title: Converting spring xml to java configuration with implicit setter autowiring and ComponentScan
body: <p>I have two classes: vehicle.Tire and vehicle.Car.</p>
  
  <pre><code>package vehicle;
  @Named
  public class Tire {
      private String age;
  }
  
  package vehicle;
  @Named
  public class Car {
      private Tire tire;
  
      // Spring calls this setter because default-autowire="byName" of xml configuration
      public void setTire(Tire newTire) {
          this.tire = newTire;
      }
  
      public Tire getTire() {
          return this.tire;
      }
  }
  </code></pre>
  
  <p>The following spring xml works fine.</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
                         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
     default-autowire="byName"&gt;
  
    &lt;context:component-scan base-package="vehicle" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>I tried to create a java configuration above:</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages={"vehicle"})
  public VehicleConfig {
  }
  </code></pre>
  
  <p>I'm <strong>not</strong> using @Inject nor @Autowired annotations in the classes, but spring <strong>autowires</strong> and it works with xml.
  Using java configuration, the method setTire of Car is not called :( </p>
  
  <p>What is missing? How can I change java configuration <strong>using</strong> component scan <strong>without</strong> modifying Car and Tire classes? Is there <strong>default-autowire="byName"</strong> xml tag attribute equivalent in java? </p>
  
  <p>I used the class above to test java configuration</p>
  
  <pre><code>@Test
  public class VehicleConfigTest  {    
      public void testTire() {
          AnnotationConfigApplicationContext applicationContext = 
              new AnnotationConfigApplicationContext();
  
          applicationContext.register(VehicleConfig.class);
  
          applicationContext.refresh();
  
          Car car = applicationContext.getBean(Car.class);
          Assert.assertNotNull(car.getTire());
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>