相关链接
Spring Security mvnrepository
1. pom 引入
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.27</version>
</dependency>
2. 创建 UserBO 实现 UserDetails(spring security 中)
public class UserBO implements UserDetails {private String password;private String username;private List<GrantedAuthority> authorities;private boolean accountNonExpired;private boolean accountNonLocked;private boolean credentialsNonExpired;private boolean enabled;
}
3. 创建 service 实现 UserDetailsService
@Service
public class UserDetailsDetailsService implements IUserDetailsService {@AutowiredIAccountInfoService accountInfoService;@Overridepublic UserBO loadUserByUsername(String username) throws UsernameNotFoundException {AccountInfo ai = accountInfoService.findByUsername(use