01-SpringSecurity初体验

创建工程

选择依赖

这里只需要引入上面两个依赖即可, next

重点: 只要加入了 Security 的依赖,项目中的所有接口统统被保护起来了!

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello(){
        return "Hello Security!";
    }

}

这时启动项目,访问 /hello 你会发现 Security 会自动的重定向到 /login 页面上面来了

默认用户名: user

默认密码为: 项目启动时控制台打印的

源码下载地址:https://github.com/XiaoHuiHuiT/SpringSecurity-case/releases/tag/1.0

posted @ 2020-05-13 22:15  Leader_TBlog  阅读(117)  评论(0编辑  收藏  举报