title: Spring @Profile and autowiring matching
body: <p>I'm using Spring framework (ver 3.2) and after some refactoring in my application I've faced with the problem with Autowiring with Profile configuration. </p>
  
  <p>Let say I have one interface which is implemented by two classes. These classes implements bunch of methods depending on environment settings. Actually I have 3 different profile properties profile1, profile2 and profile3. Using profiles works well but here for the first time I have a little problem because class cannot be injected due to finding 2 candidates. </p>
  
  <pre><code>public interface Iexample {
    public void doSomething();
  }
  
  @Profile("profile1")
  public class classA implements Iexample {
    doSomething(){..}
  }
  
  @Profile("{profile2, profile3}")    
  public class ClassB implements Iexample {
    doSomething(){..}
  }
  
  public class Test1 {
  
  @Autowired
  Iexample example; //Should use implementation based on profile1 or profile2
  
  }
  
  public class Test2 {
  
  @Autowired
  Iexample example; //Should use implementation based on profile3 only
  
  }
  </code></pre>
  
  <p>Current property configured:</p>
  
  <pre><code>spring.profiles.active= profile1,profile3
  </code></pre>
  
  <p>Possible configuration </p>
  
  <ul>
  <li>profile1, profile3</li>
  <li>profile2, profile3</li>
  </ul>
  
  <p>Is any way to specify which class should be implemented in any case (something like @Qualifier) ?</p>
  
  <p>Why not @ActiveProfiles ?</p>
  
  <blockquote>
    <p>ActiveProfiles is a class-level annotation that is used to declare
    which active bean definition profiles should be used when loading an
    ApplicationContext for test classes.</p>
  </blockquote>
  
  <p>In this case I need to know if there's any way to indicate which class depending on the profile should be injected.</p>
  
  <p>Please have a look at the example below.</p>
  
  <pre><code>@Controller
  public class exampleController {
      @Autowired
      // Suppose that this can be possible
      @Qualifier("{profile1, profile2}")
      Iexample example
  }
  </code></pre>
  
  <p>If Qualifier specified in that way may work then I will be able to resolve this problem.</p>
  
  <p>Thanks</p>