title: How to overwrite Spring service beans by name, using annotations only
body: <p>Given I have a Spring bean configured as</p>
  
  <pre><code>@Service("myService")
  public class DefaultService extends MyService {
  }
  </code></pre>
  
  <p>and a class using this bean</p>
  
  <pre><code>public class Consumer {
      @Autowired
      @Qualifier("myService")
      private MyService service;
      ...
  }
  </code></pre>
  
  <p>I now want my project, that includes the preceding classes, to have <code>Consumer</code> another implementation of <code>MyService</code> being injected. Therefore I would like to overwrite the bean <code>myService</code></p>
  
  <pre><code>@Service("myService")
  public class SpecializedService implements MyService {
  }
  </code></pre>
  
  <p>resulting in <code>Consumer</code> carrying now an instance of <code>SpecializedService</code> instead of <code>DefaultService</code>. By definition I cannot have two beans with the same name in the Spring container. How can I tell spring, that the definition of the new service shall overwrite the older one? I don't want to modify the <code>Consumer</code> class.</p>