可以用SecurityContextHolder来获取用户信息
public static User getAdminUser(){ SecurityContext ctx=SecurityContextHolder.getContext(); if(ctx!=null){ Authentication auth=ctx.getAuthentication(); if(auth!=null&&auth instanceof User) return (User)auth; } return null; }