This post will discuss how to disable security on a Spring Boot project without removing security dependency from the application.

To secure our Spring Boot application, we can add the spring-boot-starter-security dependency to pom.xml, as shown in the following example:

 
If Spring Security is found on the classpath, the web browser will prompt the user to sign in. To bypass this form-based authentication, we can disable web security on our project. There are several ways to achieve this:

1. Extending WebSecurityConfigurerAdapter

The easiest way is to extend the WebSecurityConfigurerAdapter abstract class and override its configure() method such that it allows unauthenticated access to all endpoints, as shown in the following example:

2. Excluding SecurityAutoConfiguration

We can use the exclude attribute of @SpringBootApplication to disable the SecurityAutoConfiguration auto-configuration class, as shown in the following example:

 
Note that we can also control the list of auto-configuration classes to exclude by using the spring.autoconfigure.exclude property in application.properties:

 
This can also be done in the application.yml configuration file, as shown below:

That’s all about disabling Spring Boot Security.