StackOverflowError in spring oauth2 with custom ClientDetailsService

后端 未结 4 450
面向向阳花
面向向阳花 2021-02-04 11:02

I made my own implementation of ClientDetailsService:

@Service
public class JpaClientDetailsService implements ClientDetailsService {
    @Autowired
    private          


        
4条回答
  •  梦谈多话
    2021-02-04 11:33

    I had similar problem. Finally I resolved bug when I gave my clientDetailsService another name i.e. myClientDetailsService and then injected this by name in AuthorizationServerConfig class:

    @Configuration
    @EnableAuthorizationServer
    public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
    
        @Resource(name = "myClientDetailsService")
        private ClientDetailsService clientDetailsService;
    ...
    

    I think that if my own implementation of ClientDetailsService wasn't yet created Spring inject into AuthorizationServerConfig some kind of proxy.

    So, if you want to resolve this kind of bug you must be sure that Spring inject proper ClientDetailsService in AuthorizationServerConfig. You can achieve this if you:

    1. give spring information about preference of your own ClientDetailsService (Arnaud answer), or
    2. inject this service by name

提交回复
热议问题