Method-level security applies access rules directly to individual methods using annotations, giving finer control than URL security by protecting the actual operation regardless of which entry point triggers it.
A transferFunds() method is annotated with @PreAuthorize("hasRole('ACCOUNT_OWNER')") so the check applies whether it's called from a REST controller or an internal batch job, unlike a URL-only rule which would only cover the HTTP entry point.
@PreAuthorize("hasRole('ACCOUNT_OWNER')")
public void transferFunds(Long accountId, BigDecimal amount) {
// transfer logic
}A concise interview answer is
I'd use @PreAuthorize or @Secured on individual methods after enabling @EnableMethodSecurity. The advantage is fine-grained, consistent enforcement at the actual operation, so the rule applies no matter which code path calls the method, not just requests that go through a specific controller endpoint.
Last updated: 16 July 2026
Previous question: How does Spring Security protect against Cross-Site Request Forgery (CSRF) attacks, and under what circumstances might you disable CSRF protection?