Spring Boot project shows the Login page

前端 未结 3 1596
闹比i
闹比i 2020-12-29 19:51

I created a Spring boot project with the Spring initializer and only have the starter code so far.

The sample code

@Spring         


        
相关标签:
3条回答
  • 2020-12-29 20:24

    if you really want to disable this login page you may disable your class where is:

    public class SecurityConfig extends WebSecurityConfigurerAdapter {
    

    this class is not necessary in my opinion you haven't create this class whose extends WebSecurityConfigurerAdapter

    0 讨论(0)
  • 2020-12-29 20:37

    If you don't want login page (from Spring-Security) remove the following dependency from your pom.xml

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

    Or if you want to use the Spring-Security then on console it will display the default password like below :

    Using default security password: ce6c3d39-8f20-4a41-8e01-803166bb99b6
    

    the default username will be user

    0 讨论(0)
  • 2020-12-29 20:40

    That is the default behavior. to change this, you have a few options:

    You can remove the Spring Boot Security dependency:

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

    You can desable autoconfiguration. To do so; in your main class, to: @SpringBootApplication append: (exclude = { SecurityAutoConfiguration.class }) so that it looks like:

       @SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
       public static void main(String[] args) {
                SpringApplication.run(SpringBootSecurityApplication.class, args);
            }
        }
    

    you can also do this from the application.properties file

    For more information on desableing Auto-Configuration and setting up your own. Reference: Spring Boot Security Auto-Configuration

    0 讨论(0)
提交回复
热议问题