1.引入依赖(基于SpringBoot项目)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
2.配置用户名密码的三种方式:(默认用户名为user,密码为控制台输出的值)
2.1.在配置文件中配置
spring.security.user.name=username
spring.security.user.password=password