Spring Security的快速入门
1、创建SpringBoot工程
2、引入相关依赖
3、编写Controller进行测试
第一步:创建工程




第二步:引入依赖
在pom.xml文件中,将在Spring-boot框架上引入security。如下:
<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>
到此,引入完毕。
第三步:编写Controller进行测试
@RestController
@RequestMapping("/test")
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "hello security";
    }
}
可以修改一下端口。

启动测试。]
浏览器输入:http://localhost:8088/test/hello
到此说明Security起作用了,需要登录验证。
默认的用户名是:user     
密码就在控制台随机生成。


到此,入门案例OK。
