java - Spring : Autowired bean is null -


i working on spring-mvc application in autowiring field, getting set null. checked solutions on net same problem, describe, should not create new instance of classes when working, rather spring. tried well, complains resource not found.

here class :

@service @transactional public class googleauthorization{      @autowired     private drivequickstart drivequickstart;  // guy null      public void savecredentials(final string authcode) throws ioexception {          googletokenresponse response = flow.newtokenrequest(authcode).setredirecturi(callback_uri).execute();         credential credential = flow.createandstorecredential(response, null);         system.out.println(" credential access token "+credential.getaccesstoken());         system.out.println("credential refresh token "+credential.getrefreshtoken()); // fails @ below point.         this.drivequickstart.storecredentials(credential);     } 

controller code :

@requestmapping(value = "/getgooglelogin")     public string getgooglelogin(httpservletrequest request, httpservletresponse response, httpsession session,model model) {         /* applicationcontext applicationcontext = new classpathxmlapplicationcontext("../web-inf/spring/root-context.xml");         googleauthorization helper = (googleauthorization) applicationcontext.getbean("helper");*/         googleauthorization helper = new googleauthorization(); } 

i tried getting via root-context.xml can see above, no matter path put, not find it.

drivequickstartimpl :

@service @transactional public class drivequickstartimpl implements drivequickstart{ // these below guys work fine.  @autowired     private personservice personservice;      @autowired     private googledriveservice googledriveservice;      @autowired     private groupattachmentsservice groupattachmentsservice;      @autowired     private groupaccountservice groupaccountservice; } 

what doing wrong. nice. lot.

update

image root-context.xml belongs :

enter image description here

just autowire googleauthorization helper (you can in spring-managed controller):

@service @transactional public class drivequickstartimpl implements drivequickstart{      // other stuff...      @autowired      private googleauthorization helper;       @requestmapping(value = "/getgooglelogin") public string getgooglelogin(httpservletrequest request, httpservletresponse response, httpsession session,model model) {         // use "helper" } 

if autowire helper, injected , managed spring. spring build , autowire correctly.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -