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:
![](https://www.linuxcommands.site/wp-content/uploads/2021/03/image-10-1024x275.png)
Default user name: user
The password will be output in the IDE console as follows:
![](https://www.linuxcommands.site/wp-content/uploads/2021/03/image-9-1024x89.png)
If you don’t want to use login authentication, you can disable it in two ways:
- 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:
![](https://www.linuxcommands.site/wp-content/uploads/2021/03/image-11-1024x256.png)
Of course, you can also remove the spring-boot-starter-security dependency.