How to use @PreAuthorize annotation in a spring boot application

@PreAuthorize annotation is from the Spring Security framework that allows you to define method-level security rules for securing access to methods in your RESTful API endpoints.