一 前言
安全管理框架中,Shiro和SpringSecurity都是响当当的存在。
相对于 Shiro,在 SSM/SSH 中整合 Spring Security 都是比较麻烦的操作,所以,Spring Security 虽然功能比 Shiro 强大,但是使用反而没有 Shiro 多(Shiro 虽然功能没有 Spring Security 多,但是对于大部分项目而言,Shiro 也够用了)。
但是springboot出来以后,就可以0配置整合SpringSecurity了,简直不要太方便。
废话不多说,下面开始学习整合
一 初体验
1.导包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
2.测试
@RestController
public class HelloController
{
@GetMapping("/hello")
public String hello() {
return "Hello";
}
}
访问http://localhost:8080/hello 会自动跳到login页面
默认用户名 user
默认密码在控制台显示