title: Autowiring a bean based on a property
body: <p>I have two beans, <code>beanA</code> and <code>beanB</code>, in my Spring config. Both of these beans implement the same interface. I have a class with an autowired field of the interface type (i.e. it will be populated with an instance of <code>beanA</code> or <code>beanB</code>).</p>
  
  <p>Initially there was only one bean, so I simply used the <code>@Autowired</code> annotation and the field was populated. However, now there's two potential beans that could be autowired. I want to autowire the bean based on the existence of a property in one of my <code>.properties</code> resources. Is there any elegant way to do this?</p>
  
  <p>The solution I'm using now is to use the <code>@Qualifier</code> annotation on the autowired field to specify <code>beanA</code> and then make a check to see if the property exists in code. If it does, I reassign the field to an instance of <code>beanB</code>. It's a very clunky way of doing it, so I'm looking for a better option.</p>