Spring Boot project shows the Login page

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


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


When you include spring-boot-starter-security then the login page will automatically be shown.

To remove this login page-

  1. If you use Maven then removing this dependency and rebuild the project. Already there are some answers for this. Just remove the block (pom.xml):
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
  1. If anyone uses Gradle then, just remove the following block from dependencies block(build.gradle) and reload build.gradle:
dependencies {
    //implementation 'org.springframework.boot:spring-boot-starter-security'
    ...
}
  1. If you do not want to change the config file like pom.xml or build.gradle then source code level change will be the best suit for you. To do this, need to update the main class with, change @SpringBootApplication annotation with @SpringBootApplication(exclude = {SecurityAutoConfiguration.class}). This excludes parameter will remove Security configuration.
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class SpringCacheApplication {

    public static void main(String[] args) {
    ...
    }
    ...
}
  1. Moreover, if you want to keep the login page, then you can log in with generated security password. You can find it into console, looks like: Using generated security password: d408ce6f-470d-4**4-950a-81**9651f321
{
"usename" : "user",
"password": "d408ce6f-470d-4**4-950a-81**9651f32"
}

For more information, you can read Spring Security.


You can add a class in your Project, for Web Security configuration as follows:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests().antMatchers("/*").permitAll()
                .and()
                .csrf().disable();

    }
}