title: Spring boot, @Autowired
body: <p>i'm new in spring There's something I don't understand</p>
  <p>Spring automatically register the class that implement interface,
  So we can code like below</p>
  <pre><code>@Service
  public class MyServiceImpl implements MyService{
      @Override
      public String getHello( ){
          return &quot;hello&quot;;
      }
  }
  
  @RestController
  public class DIController{
      MyService myService;
      
      @Autowired
      public DIController(MyService myService){
          this.myService = myService;
      }
      
      @GetMapping(&quot;/hello&quot;)
      public String getHello( ){
          return myService.getHello( );
      }
  }
  </code></pre>
  <p>instead of this</p>
  <pre><code>MyServiceImpl myServiceImpl;
  </code></pre>
  <p>However, what if there are several implementations? like this
  how we can register the Specific Class(ex. MyServiceImpl2)</p>
  <pre><code>@Service
  public class MyServiceImpl1 implements MyService{
      @Override
      public String getHello( ){
          return &quot;hello&quot;;
      }
  }
  
  @Service
  public class MyServiceImpl2 implements MyService{
      @Override
      public String getHello( ){
          return &quot;hello&quot;;
      }
  }
  </code></pre>
  <p>thanks a lot!</p>