In Spring Security, how can you implement method-level security annotations?
- Use the @MethodSecurity annotation to secure methods.
- Apply @PreAuthorize and @PostAuthorize annotations.
- Use @EnableMethodSecurity with @Configuration class.
- Define method-level security in the application.properties file.
Method-level security annotations in Spring Security are implemented by using @EnableMethodSecurity in a @Configuration class and applying @PreAuthorize and @PostAuthorize annotations on methods. Options 1 and 4 are incorrect, while Option 2 is partially correct but not the recommended approach.
Loading...
Related Quiz
- How do you handle situations where a service registered with Eureka becomes unavailable?
- How can you customize the security configurations when performing integration testing with @SpringBootTest in Spring Boot?
- What is the primary use of WebFlux in a Spring Boot application?
- Which annotation is used to define a bean in the Spring context?
- How would you implement a custom caching strategy in Spring Boot if the default ones do not meet your requirements?