02-security初探
1、引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2、开启启动类,会发现有一个自动生成的密码

3、编写控制类,进行访问
@RestController
@RequestMapping("/hello")
public class HelloSecurityController {
@RequestMapping("/world")
public String sayHello(){
return "Hello Spring Security安全管理框架";
}
}
4、发现访问这个路径时,会先进行用户登录验证,密码就是刚才自动生成的那个,用户名默认是user


浙公网安备 33010602011771号