title: Spring can't autowire class
body: <p>I have the following Spring @Configuration:</p>
  
  <pre><code>@Bean
  @Qualifier("mongo")
  public MongoFacade mongo(Environment env){
      final String host = env.getProperty("database.host");
      final MongoClient mongoClient = new MongoClient(host);
      return new MongoFacade(mongoClient, "test-db");
  }
  
  @Bean
  public MessageStore&lt;Event&gt; eventStore(@Qualifier("mongo") MongoFacade mongo, ObjectMapper mapper) {
      return new MongoMessageStore&lt;&gt;(mongo, mapper);
  }
  </code></pre>
  
  <p>When I launch my application an exception is thrown and the cause is:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventStore' defined in it.m.MyConfiguration: Unsatisfied dependency expressed through constructor argument with index 0 of type [base.backend.persistence.impl.mongo.MongoFacade]: : No qualifying bean of type [base.backend.persistence.impl.mongo.MongoFacade] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=mongo)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [base.backend.persistence.impl.mongo.MongoFacade] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=mongo)}
  </code></pre>
  
  <p><code>MongoFacade</code> class is a real class, and don't implements interfaces, I've also tried to remove the <code>Environment</code> dependency from the method, but still doesn't work.</p>
  
  <p>Removing the <code>@Qualifier</code> annotation the error is:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [base.backend.persistence.impl.mongo.MongoFacade] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
  </code></pre>
  
  <p>MongoFacade is a simple facade for MongoClient class that works with my PersistenceId class:</p>
  
  <pre><code>public class MongoFacade {
  
  public static final String DEFAULT_NAME = "default";
  
  private final MongoClient mongo;
  private final String defaultName;
  
  public MongoFacade(MongoClient mongoClient) {
      this(mongoClient, DEFAULT_NAME);
  }
  public MongoFacade(MongoClient mongoClient, String defaultName) {
      this.mongo = mongoClient;
      this.defaultName = defaultName;
  }
  
  public Document findOne(PersistenceId id){
      final MongoCollection&lt;Document&gt; collection = collection(id);
      final String documentId = documentId(id);
  
      return collection.find(eq("_id", documentId)).first();
  }
  
  public UpdateResult updateOne(PersistenceId id, Document update) {
      final MongoCollection&lt;Document&gt; collection = collection(id);
      final String documentId = documentId(id);
  
      return collection.updateOne(eq("_id", documentId), update);
  }
  </code></pre>