![2a654f98d97ef1a80b71371c3be80cf1.png](https://img-blog.csdnimg.cn/img_convert/2a654f98d97ef1a80b71371c3be80cf1.png)
一、前言
Spring Security
和 Apache Shiro
都是安全框架,为Java应用程序提供身份认证和授权。
二者区别
- Spring Security:
重
量级安全框架 - Apache Shiro:
轻
量级安全框架
关于shiro的权限认证与授权可参考小编的另外一篇文章 : SpringBoot集成Shiro 实现动态加载权限
二、SpringBoot集成Spring Security入门体验
基本环境 : springboot 2.1.8
1、引入Spring Security依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
2、新建一个controller测试访问
@RestController
public class IndexController {
@GetMapping("/index")
public String index() {
return "Hello World ~";
}
}
3、运行项目访问 http://127.0.0.1:8080/index
温馨小提示:在不进行任何配置的情况下,Spring Securit