They differ in intent, not in wiring. @Repository additionally translates persistence exceptions.
@Component // generic - anything Spring should manage
@Service // business logic
@Repository // data access + exception translation
@Controller // web layer, returns view names
@RestController // @Controller + @ResponseBody
@Repository
public class JdbcOrderRepository {
// SQLException is translated to DataAccessException here
}
All four register a bean.
Only @Repository wraps vendor SQL exceptions in Spring's DataAccessException hierarchy.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11