入门
概述
1、Spring Security 基于 Spring 框架,一套 Web 安全性的完整的解决方案
2、核心功能
(1)用户认证(Authentication):系统认为用户是否可以登录
(2)用户授权(Authorization):判断用户是否有权限执行某操作
3、特点
(1)Spring 无缝整合
(2)全面的权限控制
(3)专门为 Web 开发设计
(4)对整个框架进行分层抽取,分成核心模块和 Web 模块,单独引入核心模块可以脱离 Web 环境
(5)重量级,依赖很多组件
4、Shiro 特点
(1)轻量级,对性能有更高要求的互联网应用有更好表现
(2)优点:不局限于 Web 环境,可以脱离 Web 环境使用
(3)缺点:在 Web 环境下一些特定的需求,需要手动编写代码定制
5、一般
(1)SSM + Shiro
(2)Spring Boot + Spring Security
快速开始
1、创建 Spring Boot 工程
2、引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
3、编写 Controller
@RestController
@RequestMapping("/test")
public class TestController {
@GetMapping("hello")
public String hello(){
return "springSecurity";
}
}
4、默认用户
(1)用户名:user
(2)密码:随机生成,控制台查看

浙公网安备 33010602011771号