java - spring-data-mongodb customRepository can't use dependency injection -


i trying use customrepository use criteria in repository. create customrepositoryimpl , run success. found ,the property added @autowire annotation can't injected automatically. here code:

public class logmessagerepositoryimpl implements logmessagerepositorycustom{     @resource     private mongotemplate mongotemplate;      public list<logmessage> findbycriteria(){          return mongotemplate.find(query(where("level").regex("info")),logmessage.class);     }  } 

mongotemplate null;

i tried debug ,and find bean definition's dependson null.

can't figure out why?

  1. try use @autowired instead of @resource
  2. are sure bean called "mongotemplate" in spring xml-config file? provide slice of coniguration file related mongo?

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -