0
点赞
收藏
分享

微信扫一扫

SpringSecurity入门


前言
👏作者简介:我是笑霸final,一名热爱技术的在校学生。
📝个人主页:​个人主页1​ || ​​笑霸final的主页2​​​

📕系列专栏::本文写在java专栏​ 📧如果文章知识点有错误的地方,请指正!和大家一起学习,一起进步👀

SpringSecurity入门

  • ​​SpringSecurity简介​​
  • ​​入门案例​​
  • ​​创建springboot工程与引入相关依赖​​
  • ​​编写controller案例测试​​
  • ​​测试路径​​

SpringSecurity简介

pring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架。它提供了一组可以在Spring应用上下文中配置的Bean,充分利用了Spring IoC,DI(控制反转Inversion of Control ,DI:Dependency Injection 依赖注入)和AOP(面向切面编程)功能,为应用系统提供声明式的安全访问控制功能,减少了为企业系统安全控制编写大量重复代码的工作。

入门案例

​采用springboot+SpringSecurity组合方式​​实现简单认证的案例

创建springboot工程与引入相关依赖

SpringSecurity入门_java

SpringSecurity入门_spring boot_02

编写controller案例测试

目录结构

SpringSecurity入门_spring_03


测试代码如下

package com.xbfinal.myspringsecurity.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class TestSedurity {
@GetMapping("hello")
public String hello(){

return "hello SpringSecurity";
}
}

修改端口号

SpringSecurity入门_spring_04

测试路径

输入密码后进入测试页面

SpringSecurity入门_spring_07



举报

相关推荐

0 条评论