admin 管理员组

文章数量: 887031


2023年12月23日发(作者:java数组可以存储不同类型的)

} public void setUsername(String username) { me = username; } public void setPassword(String password) { rd = password; } public Integer getStatus() { return status; } public void setStatus(Integer status) { = status; } public List getRoles() { return roles; } public void setRoles(List roles) { = roles; } @JsonIgnore @Override public Collection getAuthorities() { return roles; } @Override public String getPassword() { return password; } @Override public String getUsername() { return username; } @JsonIgnore @Override public boolean isAccountNonExpired() { return true; } @JsonIgnore @Override public boolean isAccountNonLocked() { return true; } @JsonIgnore @Override public boolean isCredentialsNonExpired() { return true; }

springboot_security_oauth e 0.0.1-SNAPSHOT 4.0.0 e oauth_server 0.0.1-SNAPSHOT spring-boot-starter-web spring-boot-starter-security spring-cloud-starter-oauth2 mysql mysql-connector-java 5.1.48 mybatis-spring-boot-starter 2.1.0 1. 配置

public Integer getStatus() { return status; } public void setStatus(Integer status) { = status; } public List getRoles() { return roles; } public void setRoles(List roles) { = roles; } @JsonIgnore @Override public Collection getAuthorities() { return roles; } @Override public String getPassword() { return password; } @Override public String getUsername() { return username; } @JsonIgnore @Override public boolean isAccountNonExpired() { return true; } @JsonIgnore @Override public boolean isAccountNonLocked() { return true; } @JsonIgnore @Override public boolean isCredentialsNonExpired() { return true; } @JsonIgnore @Override public boolean isEnabled() { return true; }}

public interface UserMapper { @Select("select * from sys_user where username=#{username}") @Results({ @Result(id = true, property = "id", column = "id"), @Result(property = "roles", column = "id", javaType = , many = @Many(select = "Uid")) }) public SysUser findByUsername(String username);}5. 编写UserDetailService的实现类UserServicepublic interface UserService extends UserDetailsService {}UserServiceImpl@Service@Transactionalpublic class UserServiceImpl implements UserService { @Autowired private UserMapper userMapper; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return Username(username); }}6. 编写 SpringSecurity配置类


本文标签: 数组 编写 类型 配置 作者