SpringBoot 之安全快速入门

SpringBoot 之安全快速入门

QuickStart

(1)添加依赖

1
2
3
4
5
6
7
8
<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>

(2)添加配置

1
2
3
spring.security.user.name = root
spring.security.user.password = root
spring.security.user.roles = USER

(3)启动应用后,访问任意路径,都会出现以下页面,提示你先执行登录操作。输入配置的用户名、密码(root/root)即可访问应用页面。

img