简体   繁体   中英

Spring Security AuthenticationManager

Good evening!

Faced the problem of Spring Security: Could not autowire. No beans of 'AuthenticationManager' type found.

Should I override this method in WebSecurityConfig and mark it as @Bean? If so, could you explain how to do this?

I'm using Java Config.

No you don't want to override that method unless you have custom authentication manager. Override two configure methods in Config class,

 public class AppConfig extends WebSecurityConfigurerAdapter {
      @Override
      public void configure(AuthenticationManagerBuilder builder)
              throws Exception {
          builder.authenticationProvider(new CustomAuthenticationProvider());
      }
      @Override
      protected void configure(HttpSecurity http) throws Exception {
    }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM