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?
- try use
@autowired
instead of@resource
- are sure bean called "mongotemplate" in spring xml-config file? provide slice of coniguration file related mongo?
Comments
Post a Comment