Could not autowire field: private org.springframework.security.authentication.AuthenticationManager

前端 未结 4 2073
终归单人心
终归单人心 2021-02-07 01:53

I\'m trying to create OAuth2 Server Provider using this tutorial Spring OAuth2 . The main difference between example and my project - I do not use Spring Boot. I try to split th

相关标签:
4条回答
  • 2021-02-07 02:08

    Create another WebSecurityConfigurerAdapter class that will be the "main" configuration and add the following code in order to expose an AuthenticationManager bean:

    @Bean
    public AuthenticationManager customAuthenticationManager() throws Exception {
      return authenticationManager();
    }
    
    0 讨论(0)
  • 2021-02-07 02:16

    add this line in your servlet-context.xml

    <beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
    
    0 讨论(0)
  • 2021-02-07 02:20

    After you add the bean You should remove @Autowired from authenticationManager

      private AuthenticationManager authenticationManager;
      @Bean
      public AuthenticationManager customAuthenticationManager() throws Exception {
          return authenticationManager();
      }
    
    0 讨论(0)
  • 2021-02-07 02:24

    Solution: Just remove protected void configure(AuthenticationManagerBuilder auth) method. According to javadoc I don't need this method.

    0 讨论(0)
提交回复
热议问题