title: Custom mongoDB query with Spring MongoDB Template
body: <p>I have this classes:</p>
  
  <p>IUserRepository (For CRUD)</p>
  
  <pre><code>@Transactional
  public interface IUserRepository extends  MongoRepository&lt;User, String&gt;,
      UserRepositoryCustom {
  }
  </code></pre>
  
  <p>UserRepositoryCustom (For Custom)</p>
  
  <pre><code>public interface UserRepositoryCustom {
   public User getUserByEmail(String email); 
   public User getUserByEmailAndPassword(String email, String password); 
   public List&lt;User&gt; getOnlineUsers();
  }
  </code></pre>
  
  <p>UserRepositoryImpl (Custom IMPL)</p>
  
  <pre><code>public class UserRepositoryImpl {
  
      @Autowired
      private MongoTemplate mongoTemplate;
  
      public User getUserByEmail(String email) {
          Query searchUserQuery = new Query(Criteria.where("email").is(email));
          return mongoTemplate.findOne(searchUserQuery, User.class);
      }
  
      public User getUserByEmailAndPassword(String email, String password) {
          Query searchUserQuery = new Query(Criteria.where("email").is(email)
                  .andOperator(Criteria.where("password").is(password)));
          return mongoTemplate.findOne(searchUserQuery, User.class);
      }
  
      public List&lt;User&gt; getOnlineUsers() {
          Query searchUserQuery = new Query(Criteria.where("online").is(true));
          return mongoTemplate.find(searchUserQuery, User.class);
      }
  }
  </code></pre>
  
  <p>And Service for CRUD implementation:</p>
  
  <pre><code>@Repository("userService")
  @Transactional
  public class UserService {
  
      @Autowired
      private IUserRepository userRepository;
  
      public List&lt;User&gt; getAll() {
          return userRepository.findAll();
      }
  
      public User getUser(String deviceRegistrationID){
          return userRepository.findOne(deviceRegistrationID);
      }
  
      public void addUser(User user){
          userRepository.save(user);
      }
  
      public User editUser(User user){
  
           User findUser = getUser(user.getDeviceRegistrationID());
           findUser.setLatitude(user.getLatitude());
           findUser.setLongitude(user.getLongitude());
           findUser.setOnline(true);
  
           return userRepository.save(findUser);       
      }
  }
  </code></pre>
  
  <p>When I start the server I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.extendsme.service.IUserRepository com.extendsme.service.UserService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IUserRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property get found for type com.extendsme.model.User
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4961)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5455)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.extendsme.service.IUserRepository com.extendsme.service.UserService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IUserRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property get found for type com.extendsme.model.User
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:444)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:418)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:546)
      at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
      at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
      ... 22 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.extendsme.service.IUserRepository com.extendsme.service.UserService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IUserRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property get found for type com.extendsme.model.User
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
      ... 35 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IUserRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property get found for type com.extendsme.model.User
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1468)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:912)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
      ... 37 more
  Caused by: org.springframework.data.mapping.PropertyReferenceException: No property get found for type com.extendsme.model.User
      at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:74)
      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:325)
      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:351)
      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:351)
      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:305)
      at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:269)
      at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:240)
      at org.springframework.data.repository.query.parser.Part.&lt;init&gt;(Part.java:75)
      at org.springframework.data.repository.query.parser.PartTree$OrPart.&lt;init&gt;(PartTree.java:189)
      at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:279)
      at org.springframework.data.repository.query.parser.PartTree$Predicate.&lt;init&gt;(PartTree.java:259)
      at org.springframework.data.repository.query.parser.PartTree.&lt;init&gt;(PartTree.java:68)
      at org.springframework.data.mongodb.repository.query.PartTreeMongoQuery.&lt;init&gt;(PartTreeMongoQuery.java:47)
      at org.springframework.data.mongodb.repository.support.MongoRepositoryFactory$MongoQueryLookupStrategy.resolveQuery(MongoRepositoryFactory.java:128)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:304)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:161)
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:162)
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:44)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
      ... 45 more
  </code></pre>
  
  <p>I have the error only when my CRUD interface implements my custom interface too.
  What's wrong?</p>