SpringSecurity默认用户认证

1. 新建SpringBoot项目

SpringSecurity默认用户认证_第1张图片

SpringSecurity默认用户认证_第2张图片

2. 项目依赖

<dependencies>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-securityartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-thymeleafartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-devtoolsartifactId>
        <scope>runtimescope>
        <optional>trueoptional>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-configuration-processorartifactId>
        <optional>trueoptional>
    dependency>
    
    <dependency>
        <groupId>org.projectlombokgroupId>
        <artifactId>lombokartifactId>
        <optional>trueoptional>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-tomcatartifactId>
        <scope>providedscope>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-testartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.securitygroupId>
        <artifactId>spring-security-testartifactId>
    dependency>
dependencies>

3. 新建一个页面

SpringSecurity默认用户认证_第3张图片

4. 启动项目访问

  • 控制台打印出默认登录密码(用户账号默认为:user)
    在这里插入图片描述

  • 出现登录默认页面
    SpringSecurity默认用户认证_第4张图片

  • 出现登录默认页面

SpringSecurity默认用户认证_第5张图片

你可能感兴趣的:(java,spring,boot,spring)