Add spring-boot-starter-security in the file pom.xml.
Create a Spring config class that will override the required method while extending the WebSecurityConfigurerAdapter to achieve security in the application.