spring - org.springframework.data.repository always null into custom UserDetailManager -
spring - org.springframework.data.repository always null into custom UserDetailManager -
in project i've dao defined org.springframework.data.repository
class="lang-java prettyprint-override">@repositoryrestresource(path = "/user") public interface symtuserdao extends crudrepository<user, long>{ ...
it works fine in controllers @autowired (dependency injection):
class="lang-java prettyprint-override">@controller public class provecontroller { @autowired private symtuserdao dao; ...
i need utilize in custom userdetailsmanager in here dao null
public class symtusermanager implements userdetailsmanager { @autowired private symtuserdao dao;
i don't know if matters instantiate custom userdetailmanager in authorizationserverconfigureradapter's constructor
class="lang-java prettyprint-override">/** * class used configure how our authorization server (the "/oauth/token" endpoint) * validates client credentials. */ @configuration @enableauthorizationserver @order(ordered.lowest_precedence - 100) protected static class oauth2config extends authorizationserverconfigureradapter { .... public oauth2config() throws exception { userdetailsservice svc = new symtusermanager(...
why working dao (test passed in controller) doesn't work ( null) in userdetailsmanager? have utilize dao ( repository ) userdetailsmanager?
edit: zeroflagl right. updated reply according comments.
your symtusermanager not s spring bean. hence it's not created , handeled spring bean container. hence spring can't inject dependency there.
you can autowire oauth2config constructor , pass constructor parameter symtusermanager:
@configuration @enableauthorizationserver @order(ordered.lowest_precedence - 100) protected static class oauth2config extends authorizationserverconfigureradapter { private symtuserdao dao; @autowire public oauth2config(symtuserdao dao) throws exception { userdetailsservice svc = new symtusermanager(dao, ...
spring dependency-injection spring-security spring-data-rest spring-jpa
Comments
Post a Comment