弃用 WebSecurityConfigurerAdapter 类后,authenticationManagerBean 函数的替代方法是什么?

Ana*_*rhy 2 spring-security spring-boot

在 Spring Boot 2.7.4 中,WebSecurityConfigurerAdapter包含该authenticationManagerBean函数的类已被弃用

还有什么选择呢?

Lak*_*o12 5

这些天我也遇到了和你一样的问题,找到的唯一解决方案是这个

@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}
Run Code Online (Sandbox Code Playgroud)

但这导致我在测试中出现异常。我在 GitHub 上发布了一个 spring-boot 问题。请查看以了解最新情况。 https://github.com/spring-projects/spring-framework/issues/29215 这可能是一个错误