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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -