title: Spring Data MongoDB: Unable to resolve a bean for 'org.springframework.data.mongodb.core.MongoOperations'
body: <p>So I've set up Spring Data MongoDB with a Java Configuration and everything has worked fine so far. Now I wanted to use "Repositories" and created a "UserRepository". As soon as I created the corresponding Interface (extending CrudRepository) I encountered the following exception while deploying to jBoss:</p>
  
  <blockquote>
    <p>Unable to resolve a bean for 'org.springframework.data.mongodb.core.MongoOperations' 
    with qualifiers [@javax.enterprise.inject.Any(), @javax.enterprise.inject.Default()]</p>
  </blockquote>
  
  <p>Therefore I added the following method to my SpringMongoConfig:</p>
  
  <pre><code>@Bean
  public MongoOperations mongoOperations() throws Exception {
      return new MongoTemplate(mongo(), dbName);
  }
  </code></pre>
  
  <p>But it did not help and the exception persists.</p>
  
  <p>I am fairly new to Spring and therefore I quickly ran out of ideas. Can anyone help?</p>
  
  <p><strong>I fixed it...</strong></p>
  
  <p>...by adding the annotation <em>@Produces</em> to the method <em>mongoOperations()</em>:</p>
  
  <pre><code>@Bean
  @Produces
  public MongoOperations mongoOperations() throws Exception {
      return new MongoTemplate(mongo(), dbName);
  }
  </code></pre>
  
  <p>Not sure why this is necessary / why the problem occurred at all.</p>