SpringBoot 2.* security turn off login authentication

After introducing security dependency into SpringBoot, you need to log in by default to access resources.

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

After starting the app, you will be prompted to enter the user name and password:

Default user name: user

The password will be output in the IDE console as follows:

If you don’t want to use login authentication, you can disable it in two ways:

  1. Add Java annotations on the startup method: @EnableAutoConfiguration
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})

2. Add Java annotations on the startup method: @SpringBootApplication

@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})

Run the application again:

Of course, you can also remove the spring-boot-starter-security dependency.

Add a Comment

Your email address will not be published.