Table of Contents
Question
Direct solution
0, remove spring-boot-starter-security dependency
1, use the default user and password to log in
2, disable security settings or set the corresponding user and password
parsing
Home Java javaTutorial How to solve the problem that username and password are required to log in to the web page after enabling springboot security

How to solve the problem that username and password are required to log in to the web page after enabling springboot security

May 16, 2023 pm 10:02 PM
web springboot security

    Question

    How to solve the problem that username and password are required to log in to the web page after enabling springboot security

    Note: I use Spring Boot 2.0.2, which may not be useful for the 1.5.x series.

    Direct solution

    0, remove spring-boot-starter-security dependency

    If you do not actually use the security function, you can directly remove spring-boot-starter -security depends on

    1, use the default user and password to log in

    The default user name is user
    The password is a string automatically generated when the program starts

    How to solve the problem that username and password are required to log in to the web page after enabling springboot security

    2, disable security settings or set the corresponding user and password

    You can configure the corresponding user and password in application.properteis

    You can also set the corresponding user Name and password
    spring.security.user.name=user1
    spring.security.user.password=password1

    By disabling

    package com.yq;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    @SpringBootApplication(scanBasePackages = {"com.yq"})
    @EnableAutoConfiguration(exclude = {
    org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
    })
    public class WebSecurityDemoApp {
        private static final Logger log = LoggerFactory.getLogger(WebSecurityDemoApp.class);
    
        public static void main(String[] args) {
            SpringApplication.run(WebSecurityDemoApp.class, args);
        }
    
    }
    Copy after login

    parsing

    on the startup main class

    As long as our Spring Boot project references the following dependencies, the security configuration will be enabled by default.

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
    Copy after login

    If you want to use security but don’t want to enter the user name and password every time, you can disable automatic configuration directly in the Application file

    @EnableAutoConfiguration(exclude = {
    org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
    })
    Copy after login

    Or we can also configure the specified user and password, for example
    spring.security.user.name=user1
    spring.security.user.password=password1

    The above is the detailed content of How to solve the problem that username and password are required to log in to the web page after enabling springboot security. For more information, please follow other related articles on the PHP Chinese website!

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    Java Tutorial
    1659
    14
    PHP Tutorial
    1258
    29
    C# Tutorial
    1232
    24
    17 ways to solve the kernel_security_check_failure blue screen 17 ways to solve the kernel_security_check_failure blue screen Feb 12, 2024 pm 08:51 PM

    Kernelsecuritycheckfailure (kernel check failure) is a relatively common type of stop code. However, no matter what the reason is, the blue screen error causes many users to be very distressed. Let this site carefully introduce 17 types to users. Solution. 17 solutions to kernel_security_check_failure blue screen Method 1: Remove all external devices When any external device you are using is incompatible with your version of Windows, the Kernelsecuritycheckfailure blue screen error may occur. To do this, you need to unplug all external devices before trying to restart your computer.

    Comparison and difference analysis between SpringBoot and SpringMVC Comparison and difference analysis between SpringBoot and SpringMVC Dec 29, 2023 am 11:02 AM

    SpringBoot and SpringMVC are both commonly used frameworks in Java development, but there are some obvious differences between them. This article will explore the features and uses of these two frameworks and compare their differences. First, let's learn about SpringBoot. SpringBoot was developed by the Pivotal team to simplify the creation and deployment of applications based on the Spring framework. It provides a fast, lightweight way to build stand-alone, executable

    SpringBoot+Dubbo+Nacos development practical tutorial SpringBoot+Dubbo+Nacos development practical tutorial Aug 15, 2023 pm 04:49 PM

    This article will write a detailed example to talk about the actual development of dubbo+nacos+Spring Boot. This article will not cover too much theoretical knowledge, but will write the simplest example to illustrate how dubbo can be integrated with nacos to quickly build a development environment.

    How to implement form validation for web applications using Golang How to implement form validation for web applications using Golang Jun 24, 2023 am 09:08 AM

    Form validation is a very important link in web application development. It can check the validity of the data before submitting the form data to avoid security vulnerabilities and data errors in the application. Form validation for web applications can be easily implemented using Golang. This article will introduce how to use Golang to implement form validation for web applications. 1. Basic elements of form validation Before introducing how to implement form validation, we need to know what the basic elements of form validation are. Form elements: form elements are

    What are web standards? What are web standards? Oct 18, 2023 pm 05:24 PM

    Web standards are a set of specifications and guidelines developed by W3C and other related organizations. It includes standardization of HTML, CSS, JavaScript, DOM, Web accessibility and performance optimization. By following these standards, the compatibility of pages can be improved. , accessibility, maintainability and performance. The goal of web standards is to enable web content to be displayed and interacted consistently on different platforms, browsers and devices, providing better user experience and development efficiency.

    Nginx Proxy Manager Security Analysis and Protection Nginx Proxy Manager Security Analysis and Protection Sep 28, 2023 pm 01:30 PM

    NginxProxyManager Security Analysis and Protection Introduction: In Internet applications, security has always been a crucial issue. As a powerful reverse proxy and load balancing server software, Nginx plays an important role in ensuring the security of network applications. However, with the continuous development of Internet technology and the increasing number of network attacks, how to ensure the security of NginxProxyManager has become an urgent problem to be solved. This article will start from NginxProxyMana

    How to enable administrative access from the cockpit web UI How to enable administrative access from the cockpit web UI Mar 20, 2024 pm 06:56 PM

    Cockpit is a web-based graphical interface for Linux servers. It is mainly intended to make managing Linux servers easier for new/expert users. In this article, we will discuss Cockpit access modes and how to switch administrative access to Cockpit from CockpitWebUI. Content Topics: Cockpit Entry Modes Finding the Current Cockpit Access Mode Enable Administrative Access for Cockpit from CockpitWebUI Disabling Administrative Access for Cockpit from CockpitWebUI Conclusion Cockpit Entry Modes The cockpit has two access modes: Restricted Access: This is the default for the cockpit access mode. In this access mode you cannot access the web user from the cockpit

    Spring Security permission control framework usage guide Spring Security permission control framework usage guide Feb 18, 2024 pm 05:00 PM

    In back-end management systems, access permission control is usually required to limit different users' ability to access interfaces. If a user lacks specific permissions, he or she cannot access certain interfaces. This article will use the waynboot-mall project as an example to introduce how common back-end management systems introduce the permission control framework SpringSecurity. The outline is as follows: waynboot-mall project address: https://github.com/wayn111/waynboot-mall 1. What is SpringSecurity? SpringSecurity is an open source project based on the Spring framework, aiming to provide powerful and flexible security for Java applications.

    See all articles