Spring Security java.lang.StackOverflowError exception after all providers

前端 未结 2 572
感动是毒
感动是毒 2020-12-16 23:20

Environment:

  • Spring 4.1.6
  • Spring Security 4.0.1

I have 2 authentication providers - one that hits ActiveDirectory, and then one that hi

相关标签:
2条回答
  • 2020-12-16 23:39

    I had the same problem, this was the solution for me:

    @Override
    protected void configure(AuthenticationManagerBuilder
    authManagerBuilder) throws Exception {
    ...
    .userDetailsService(userDetailsService());
    ...
    }
    

    The problem where the brackets after userDetailsService - removed them and it works as expected. From your code snippet I can't be sure where you get the userDetailsService from, for me I had it @Autowired.

    0 讨论(0)
  • 2020-12-16 23:48

    I had the same problem and another solution worked in my case. The difference is, that I had simply username and password, database authentication.

    @Override
    protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception {
        authManagerBuilder
                .userDetailsService(userDetailsService())
                .passwordEncoder(passwordEncoder());
    }
    
    @Bean
    UserDetailsService userDetailsService() {
        return new UserDetailsService();
    }
    

    The fix was to add the @Override annotation to the @Bean annotated method:

    @Bean
    @Override
    UserDetailsService userDetailsService() {
        return new UserDetailsService();
    }
    
    0 讨论(0)
提交回复
热议问题