What is the purpose of the @EnableWebSecurity annotation?
A) To enable Spring Security’s web security support
B) To configure database access
C) To enable Spring Boot’s auto-configuration
D) To create REST APIs
Answer:
A) To enable Spring Security’s web security support
Explanation:
The @EnableWebSecurity
annotation is used to enable Spring Security’s web security support in a Spring application. This annotation is typically added to a configuration class that extends WebSecurityConfigurerAdapter
, allowing you to customize the security configuration, such as specifying which endpoints require authentication, configuring user roles, and setting up login mechanisms.
By using @EnableWebSecurity
, you activate Spring Security’s capabilities, ensuring that your application is protected by the security configurations defined in the application.