spring security报错:There is no PasswordEncoder mapped for the id "null"
1、问题描述:在写基于Spring cloud微服务的OAuth2认证服务时,因为Spring-Security从4+升级到5+
2、 解决方案:在security配置类中,添加
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
import org.springframework.security.crypto.password.NoOpPasswordEncoder;会显示失效,但可解决问题,亲测有效。