之前我们自定义的UserDetailsService也需要存在
/**
-
autor:liman
-
createtime:2021/7/8
-
comment:
*/
@Component
@Slf4j
public class MyUserDetailService implements UserDetailsService{
@Autowired
private PasswordEncoder passwordEncoder;
/**
-
根据用户名查找用户信息
-
@param username
-
@return
-
@throws UsernameNotFoundException
*/
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
log.info(“根据用户名查找用户信息:{}”,username);
return new User(username,passwordEncoder.encode(“123456”),
true,true,true,true,
AuthorityUtils.commaSeparatedStringToAuthorityList(“admin”));
}
}
为了避免每次重启输入的clientid的繁琐,这里在配置文件中配置一下clientid和clientsecret
security.oauth2.client