Spring Annotations





@Component for any Spring-managed component, scanned by

to respect the convention:

@Repository for persistence layer – deal with DataAccessException

@Service for service layer

@Controller for presentation layer (spring-mvc) – the dispatcher scans the classes annotated with @Controller and detects @RequestMapping annotations within them. We can only use @RequestMapping on @Controller


@RestController – The Controller only sends back the model (or resource representation) – @Controller + @ResponseBody

@RequestBody – convert incoming JSON

@ResponseBody – annotation means is that the returned value of the method will constitute the body of the HTTP response of accounts is transformed to a format suitable for REST applications, typically JSON or XML

@RequestMapping – mapping web requests onto methods in request-handling classes (produces = MediaType.APPLICATION_JSON_UTF8_VALUE)




@Transactional – start transaction (see Transaction propagations in Spring)







Leave a comment

Your email address will not be published. Required fields are marked *