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;会显示失效,但可解决问题,亲测有效。

摘自:https://blog.csdn.net/dream_an/article/details/79381459

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐